Hello.
Help plz. How change in Text Mesh Pro UGUI → Glow → color using a script?
Thnx.
Since those properties are in reality material properties, you can already access those by using the Unity API for materials. So for instance, if you wanted to change glow power, you would do something like this.
m_TextMeshPro.fontSharedMaterial.SetFloat("_GlowPower", 0.5f);
// Instead of using a string to access the material property, you could use the ShaderUtilities class I provide
m_TextMeshPro.fontSharedMaterial.SetFloat(ShaderUtilities.ID_GlowPower, 0.5f);
// Since some of the material properties can affect the mesh (size) you would need to update the padding values.
m_TextMeshPro.UpdateMeshPadding();
Now some of the Material properties are using Shader Features or Keywords which have to be enabled. Underlay and Glow for instance use Shader features and have to be enabled.
// Assuming m_sharedMaterial contains a reference to the material you are using.
m_sharedMaterial.EnableKeyword("UNDERLAY_ON");
m_shaderMaterial.DisableKeyword("UNDERLAY_INNER");
All the shader properties can be seen when selecting the shader or opening the shader in Mono or Visual Studio.
Many thanks.
My code:
m_TextMeshPro.fontSharedMaterial.SetColor(ShaderUtilities.ID_GlowColor, new Color32(255, 240, 0, 100));
Thanks!!!