Search Unity

TextMesh Pro Creating a Style programmatically

Discussion in 'UGUI & TextMesh Pro' started by HaynophGuard, Aug 1, 2018.

  1. HaynophGuard

    HaynophGuard

    Joined:
    Aug 29, 2017
    Posts:
    10
    I'd like to define styles (<style>) in an XML file and add it to a stylesheet.

    I can make the parser, but how do I create and add new styles programmatically?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Some TMP are creating styles dynamically. To do so, I believe they modified the TMP_Styles.cs and possibly the TMP_StyleSheet.cs to add a setter on the required properties.

    Assuming you are using the TMP UPM package for Unity 2018.1 and up which includes source code, your should be able to make the necessary changes.

    When grabbing text from XML, be mindful of control characters being escaped.
     
  3. HaynophGuard

    HaynophGuard

    Joined:
    Aug 29, 2017
    Posts:
    10
    I used to modify TMP back when you sold it, but every version update made it really difficult to maintain.
    So you can't do this out of the box? Are there any plans for adding this?
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This is functionality that is now more frequently used / requested.

    I can't provide on ETA on when I can add support for this but I will most certainly add it to my list.
     
  5. HaynophGuard

    HaynophGuard

    Joined:
    Aug 29, 2017
    Posts:
    10
    Thank you so much. I'm looking forward to it!!