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 Enabling outline with script

Discussion in 'UGUI & TextMesh Pro' started by io3creations, May 5, 2018.

  1. io3creations

    io3creations

    Joined:
    May 18, 2015
    Posts:
    10
    This is a Texmesh Pro noob question and might be more of a confirmation check.

    I've added a Textmesh Pro component to a GameObject in script. (The same type that is added with: GameObject->3D Object->TextMeshPro Text)
    Then, I modified certain properties (still in script). Most changes did show up but the outline didn't. More specifically, I was able to set the outline color and thickness, but the "Enable -> []" checkbox to the right of "Outline -Settings-" was still unchecked.
    As I tried a few things, it seems like that checkbox setting is related to the font material.

    So, similarly to "regular" materials, if I create a first in the Unity Editor with the desired settings (e.g. enable outline) then the scripts can change the other properties, right?
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,850
    On my cell phone so short reply.

    The outline uses a shader keyword and as such it has to be enabled on the material.

    See the following thread.
     
  3. io3creations

    io3creations

    Joined:
    May 18, 2015
    Posts:
    10
    Thanks for the reply.

    In that case, for now it seems like that it is easier to create and set up different font materials in the Editor and just change certain properties (e.g. font size) as needed. But later on there probably will be situations where I will cases that require turning on and off certain shader keyword based features.
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,850
    Unless you need to dynamically change the visual appearance of the material (which can be even done with the Animation component in Unity), it is best to use Material Presets. See the following video about Material Presets.

    The intro of this video shows a good example of animating material properties using the Animation component in Unity.
     
unityunity