I've added a Text Mesh Pro component to my GameObject, as shown here:

enter image description here

I'd like to programmatically vary the value of the Power setting under Glow, in order to create a pulsating effect for my text. Someone posted a related bit of code on the Unity Forum:

m_TextMeshPro.fontSharedMaterial.SetColor(ShaderUtilities.ID_GlowColor, new Color32(255, 240, 0, 100));

But in my case, I'd like to programmatically change the Glow parameters (specifically the Power one) to go from 0 to 1 and then back again... to create a pulsating effect.

I can't find out how to change these parameters. I am beginning to suspect that I need to edit the TextMeshPro/Distance Field Shader in order to to programmatically change the glow. Does anyone know if that is true... and if so, how to do it? Thank you!


1 Answer 1


When you don't know how to access a parameter of a shader in code, click the "Edit" button next to the material type selector to open its shader code.

Edit button

Search for "Glow" and you'll find the property declarations for the glow parameters:

[HDR]_GlowColor     ("Color", Color) = (0, 1, 0, 0.5)
_GlowOffset         ("Offset", Range(-1,1)) = 0
_GlowInner          ("Inner", Range(0,1)) = 0.05
_GlowOuter          ("Outer", Range(0,1)) = 0.05
_GlowPower          ("Falloff", Range(1, 0)) = 0.75

So now we know the power parameter is called _GlowPower under the hood. We can convert that to an ID using:

static readonly int ID_GlowPower = Shader.PropertyToID("_GlowPower");

Although it seems like the ShaderUtility you're already using includes that ID out of the box.

Since this is a float (range) property, we can set it with:

 m_TextMeshPro.fontSharedMaterial.SetFloat(ShaderUtilities.ID_GlowPower, value);
  • \$\begingroup\$ Thank you very much, this was very helpful!! I was able to set the font shared material, and get the effect I was looking for. \$\endgroup\$
    – kanamekun
    Jun 2 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .