I have here an odd situation that does not make sence to me. I just want to store in a variable of an object that is not being destroyed by Application.LoadLevel() which scene was just loaded so that my GUI shows the right stuff.
The first line in the following code for some reason prevents the 3rd line from working:
GameData.curSelectedButton = 4;
Debug.Log("just before load: " + scenename);
Application.LoadLevel(scenename);
Debug.Log("after load: " + scenename);
When I remove the first line the level “scenename” is being loaded properly (but of course my variable isn´t set). Both Debug.Log outputs are showing up in the console with and without the line and scenename is the same in both outputs.
Does anybody have a clue what´s going on here? Why would setting a variable have such an effect?