- Home /
Question by
MasterChameleonGames · Mar 11, 2019 at 08:05 PM ·
coloralphafade
Changing Alpha Thru Code Acts Weird
When I run this code, the alpha does not change either visually or in the inspector until it hits 0, and then the sprite disappears and shows the alpha as 0 in the inspector.
When I use Debug.Log() in the code, however, it reveals that the alpha is indeed changing the entire time.
I've already tried new Color() too.
public class Class: Monobehaviour {
// This is set
public TextMeshProUGUI textToFade;
void Update()
{
// If there is a text to fade
if (textToFade != null)
{
textToFade.alpha -= 1;
if (textToFade.alpha <= 0)
{
textToFade = null;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How to change the alpha element of particles/additive color? 1 Answer
How to make a "Click to Continue" text message? 1 Answer
renderer.material.color not being changed? 2 Answers
Fading between two objects in UnityScript 0 Answers
Color.a won't be shown/set correctly for values between 1 an 244 1 Answer