Search Unity

TextMesh Pro Set rich text without actually using the rich text tag

Discussion in 'UGUI & TextMesh Pro' started by Go2ready, Apr 4, 2018.

  1. Go2ready

    Go2ready

    Joined:
    May 8, 2015
    Posts:
    29
    Hello there,

    I am wondering how do you set the rich text mode in code without actually changing the input text to include rich text tag. Much like the font settings in the text mesh pro UGUI script, setting font style. Just by looking at the header, all I can see is that font style is a enum, how do you actually assign two rich text mode like bold and italic using that?

    With thanks,
     
  2. Go2ready

    Go2ready

    Joined:
    May 8, 2015
    Posts:
    29
    I guess it is using bit map?

    public enum FontStyles
    {
    Normal = 0,
    Bold = 1,
    Italic = 2,
    Underline = 4,
    LowerCase = 8,
    UpperCase = 16,
    SmallCaps = 32,
    Strikethrough = 64,
    Superscript = 128,
    Subscript = 256,
    Highlight = 512,
    }
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Using the FontStyles is the correct way.

    Code (csharp):
    1.  
    2. // Example of setting the text to bold italics.
    3. TextComponent.fontStyle = FontStyles.Bold | FontStyles.Italic;
    4.  
     
    tokar_dev and Go2ready like this.