i have a script that runs each time I reload the scene with
Application.loadLevel(Application.loadedLevel)
(i.e. each time players play one “round” in a best of x match) to reinitialize the UI
I have 3 functions that are called. One updates the Wall power cooldown text, one updates the Bomb power cooldown text, and one updates the number of round wins for each player. All 3 functions are exactly the same:
//called in roundWins to update every player's UI
public void updateWinsText(string changeToThis)
{
winsText.GetComponent<TextMesh>().text = changeToThis;
}
//called in Powers.cs when dealing with the cooldown
public void updateBombTimerText(string changeToThis)
{
bombTimerText.GetComponent<TextMesh>().text = changeToThis;
}
//called in Powers.cs when dealing with the cooldown
public void updateWallTimerText(string changeToThis)
{
wallTimerText.GetComponent<TextMesh>().text = changeToThis;
}
Whenever my initialization script runs, it calls all 3, and on the first round (i.e. right after I hit “play”) all 3 work fine. But when I reload the scene, it CALLS all 3, but the update wins function doesn’t set the UI element to the new amount of wins for the player that won the last round. I’ve been trying to figure this out for hours and I just dont get it
- I know for a fact it calls the function (tested with debug.log)
- I know for a fact it’s setting it to the correctly updated value (tested with debug.log)
- I know for a fact there are no “missing elements” in my gameobjects’ scripts (double checked, and I never destroy anything – only set active and deactive)
- I call the initialization AFTER reloading the new scene, so it’s not getting overwritten
- I know for a fact it sets it correctly on start
So… wtf is going on…?