I have some TextMeshPro UGUI text which needs to be “pulsating”. I would like to achieve this by increasing/decreasing the value of GlowOuter.
At first, I tried using an animation but I cannot seem to find a way to access this property through animation. So plan B, write a script to control this property. I again seem to be running into sort of the same problem. Now the value seems to be changing but the GlowOuter value does not change in the inspector nor does the glow change visually on the screen.
So basically this is what I have:
void Start()
{
text = GetComponent<TextMeshProUGUI>();
text.material.SetFloat("_GlowOuter", glowOuterMin);
//rend = GetComponent<Renderer>();
//rend.material.SetFloat("_GlowOuter", glowOuterMin);
Debug.Log(text.material);
elapsedTime = 0f;
growing = true;
glowing = StartCoroutine("Glow");
}
private IEnumerator Glow()
{
float glowValue = 0f;
Debug.Log("Glow");
while (true)
{
Debug.Log("Glow: " + text.material.GetFloat("_GlowOuter"));
if (elapsedTime + Time.deltaTime > rate)
{
elapsedTime = (elapsedTime + Time.deltaTime) - rate;
growing = !growing;
} else
{
elapsedTime += Time.deltaTime;
}
if (growing) glowValue = elapsedTime.Remap(0f, rate, glowOuterMin, glowOuterMax);
else glowValue = elapsedTime.Remap(0f, rate, glowOuterMax, glowOuterMin);
text.material.SetFloat("_GlowOuter", glowValue);
yield return null;
//rend.material.SetFloat("_GlowOuter", glowValue);
}
}
Anyone can offer any help? Thanks.