Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

TextMesh Pro Attempting to add custom tags to the rich text system

Discussion in 'UGUI & TextMesh Pro' started by renardmf, Jul 16, 2018.

  1. renardmf


    Jun 29, 2012

    I am trying to add a custom tag to the rich text system which would allow for more functionality based on a specific tag. I was attempting to add one in the TMP_Text.cs file following along with the other tags in the switch statement found there. But for whatever reason I can't seem to figure out how to hash my tag so that it works the same as the other tag lookups there. I tried using GetSimpleHashCode() function but it seems to give me different results when trying to hash non single character tags. I am also not sure if this is the only step needed to be able to add this new functionality.

    Any help with this would be much appreciated.

  2. Stephan_B


    Unity Technologies

    Feb 26, 2017
    Take a look in the TMP_Text.cs file around line 6151, and uncomment that first Debug.Log line of code. This will have the affect of printing the hashcode of whatever tag you just typed in the text input box.

    For instance <myCustomTag> will produce hashcode 1811234461.

    Note these are case sensitive (for the time being).

    You will need to add the closing part of the tag as well </myCustomTag>

    Then add the functionality similar to how the other tags are implemented.

    Note: The hashcode used in the parsing of the text is slightly different than that of the GetSimpleHashCode() function.
    Last edited: Jul 16, 2018