Hi, this is my first time posting here but I was wondering if someone would be able to help me with an issue I’m having with my code. Whenever I run this code, which is meant to slowly fade text by reducing its alpha, the alpha instantly sets to zero. I’m not sure if this is because the fade is happening to fast or there is an error in my code. Here is my code:
public void Fadeout (int Player, string sign, int value, int position) {
PlayerOneSavingsModIndicator.color = new Color (PlayerOneSavingsModIndicator.color.r, PlayerOneSavingsModIndicator.color.g, PlayerOneSavingsModIndicator.color.b, 1f);
if (Player == 0) {
if (position == 1) {
PlayerOneSavingsModIndicator.text = sign + value;
if (sign == "-") {
PlayerOneSavingsModIndicator.color = Color.red;
} else if (sign == "+") {
PlayerOneSavingsModIndicator.color = Color.green;
}
while (PlayerOneSavingsModIndicator.color.a > 0.0f) {
PlayerOneSavingsModIndicator.color = new Color (PlayerOneSavingsModIndicator.color.r, PlayerOneSavingsModIndicator.color.g, PlayerOneSavingsModIndicator.color.b, PlayerOneSavingsModIndicator.color.a - (Time.deltaTime / 10));
}
} else if (position == 2) {
}
} else if (Player == 1) {
} else if (Player == 2) {
} else if (Player == 3) {
}
Any help would be greatly appreciated. Thank you.