Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro What's the proper whay to deal with having different materials for same font?

Discussion in 'UGUI & TextMesh Pro' started by esteban16108, Mar 19, 2018.

  1. esteban16108

    esteban16108

    Joined:
    Jan 23, 2014
    Posts:
    158
    I'm discovering many new things as I use TMP, one of them is that the material is the same for all the instances of the font used.

    So my question is what's the proper way to handle, lets say, 2 different text objects with different effects on them using the same font with TMP?

    Thanks.
     
    eyupunity likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The answer is Material Presets. These are materials with different settings but all referencing the same font atlas texture.

    Using material presets is very efficient and avoids resource duplication.

    These are created using the material context menu.

    upload_2018-3-18_23-3-9.png

    See the following video which covers this topic.
     
  3. esteban16108

    esteban16108

    Joined:
    Jan 23, 2014
    Posts:
    158
  4. Allan_RD3

    Allan_RD3

    Joined:
    Oct 25, 2021
    Posts:
    4
    Thanks! You helped me a lot!
     
  5. mrchrissross

    mrchrissross

    Joined:
    Jun 20, 2019
    Posts:
    9
    Hello, while this works well the new material present is completely absent from the presets dropdown. This means whenever I wish to use the new present I must drag and drop it as a material. How do make this new preset appear?

    upload_2022-3-17_10-7-34.png
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The new material preset must following a naming convention where the new preset must be prefix by the name of the font asset. For instance, if the font asset name is "LiberationSans SDF" then the material preset must be named something like "LiberationSans SDF - Whatever ...".
     
  7. doseon

    doseon

    Joined:
    Mar 17, 2021
    Posts:
    39
    hi @Stephan_B

    But if you see a TextMeshPro object consisting of different presets in one UI screen, Batches goes up that much. Is there no problem with performance?