It was worked fine previously, but after some point, it's not working.
This is the code. It's not a pseudo code, actual code in game:
public Text healthText;
void Start() {
healthText = GameObject.Find("UI/InGameUI/CharacterStatus/HealthText").GetComponent<Text>();
}
void Update() {
if(healthText) {
print(health);
// healthText.text = Time.deltaTime.ToString();
healthText.text = "HP: " + health.ToString();
// healthText.text = "HP: " + health;
}
}
variable "health" is float value. I just want to print it to the screen, but it's always prints "Health: 100" even it changes.
So I printed the value to the console, but it prints well in the console and only text components was not printed properly.
So I printed Time.deltaTime instead of the health and it works!
Seriously, what the hell is happening? Is this a bug? If health variable wasn't changed, it should be also printed 100 in the console, but it's not!
Try this to another text component, still not working.