Fade out an object cause every other object to fade out
Hi everyone, I want an object (in this case a text) to gradually disappear, but when it does, every other object inside the Canvas does the same.
Here is the code of the Fade Out effect:
// Fade out message
IEnumerator FadeOutMessage () {
float t = 0;
while (t < 1) {
t += Time.fixedDeltaTime * messageAnimationSpeed;
message.material.color = new Color (1, 1, 1, Mathf.Lerp (1, 0, t));
yield return null;
}
}
As you can see, only the message is supposed to fade out, but it seems like every other object in the Canvas is linked to the material of the others, even though it doesn't make sense. This happens in every scene I try to apply this effect.
Do you know what is causing this problem and how to fix it?
Thanks in advance to everyone and have a nice day!
Comment