Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. 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 Access TMPro Material Dilate via Code

Discussion in 'UGUI & TextMesh Pro' started by renman3000, Jun 28, 2019.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,534
    Is there a way to access the TMP font material, dilate?

    I am trying to access it via code, but no luck!
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,286
    All material properties can be accessed via scripting.

    The property is called _FaceDilate. You can select the shaders in the project to see all these properties and their names.

    You should be using the TextMesh Pro ShaderUtilities class to reference these properties instead of using strings.

    Code (csharp):
    1. m_sharedMaterial.SetFloat(ShaderUtilities.ID_FaceDilate,_0.1f);
    Remember that some properties below to some ShaderKeyword like Outline group with the Mobile Distance Field shader and as such the ShaderKeyword has to be enabled in order for those property changes to be visible.
     
    renman3000 likes this.
  3. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,534
    THANK YOU!
     
  4. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,534


    Hi Stephan,
    When you say Visible, visible to/in what? Code? Inspector? Am I over thikning this and the code you provided all I need, from a front end aspect?

    Thanks again.
     
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,286
    Ie. If the Shader Keyword is disabled, nothing will appear so although you set the Outline to some value, unless you enable the Shader Keyword for the Outline the effect of the Outline will not be visible.
     
unityunity