Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Can TMPro FontStyles enum be extended?

Discussion in 'Scripting' started by Fedora_Dev, Nov 16, 2020.

  1. Fedora_Dev

    Fedora_Dev

    Joined:
    Oct 28, 2016
    Posts:
    35
    I'm trying to learn more about how to control TMPro and i'm currently looking into the VertexJitter example. I can see that an entire TMPro_Text can be animated through a script, however I am wanting individual control over portions of a text. I'm hoping I can take individual words from a text and animate only them. To do this, I was hoping to be able to use custom style tags as I see each character contains style information, however the FontStyles that contains this information is an enum, so I can't add my own values.

    Does anyone know a workaround for this?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,342
    TextMeshPro's source code is included in the Asset store package. So you could always create a copy of the code and modify it for your own use.
     
  3. Fedora_Dev

    Fedora_Dev

    Joined:
    Oct 28, 2016
    Posts:
    35
    Unfortunately, I don't have access to Text Mesh Pro on the Asset Store, only in the package manager. I did attempt to transfer TMP to the project and remove it from package tracking, however after fixing the assembly references and clearing the errors, I run into an issue where adding a TMPro text component to an object brings up the first-time launch screen for TMPro and I can't get rid of it. additionally, the component doesn't function properly. Even if I were able to copy it properly, I would have to replace every instance of TMP in the project, which would be a bit of a pain.
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,342
    Sorry Package Manager is what I meant!

    You shouldn't have to replace anything. If you remove the package manager version and include your own version it should work just fine.

    Wish I could be of more help!
     
  5. Fedora_Dev

    Fedora_Dev

    Joined:
    Oct 28, 2016
    Posts:
    35
    Unfortunately, copying TMP from the package manager to the actual project will force disconnect the monobehaviours throughout the project because the package won't have the same asset IDs associated to them after importing. It would be easier if there were
    .meta
    files in the package, but it doesn't appear there are any.

    I think I'm going to use the approach that BlaiseRoth mentioned here using link tags. I would much prefer to add my own custom tags to cut down on extra text in my dialogues, but I guess this the lesser of the two evils. Next time I start a new project, I'll likely opt to not use the package manager so I won't have to deal with this sort of issue.

    Thanks for the help anyways, Praetor!
     
    PraetorBlue likes this.