Hello all,
I’ve read everything there is in the Unity Answers and on the forums about this problem. It seems very wide spread.
Even with the simplest programs a LoadLevel will (may) cause my game to compiled as a non-dev build to crash. I wrote “may” because sometimes it actually works, but very rarely. The exact same program compiled as a dev build works exactly as expect with good load times and no crashing.
I’ve tried everything that was suggested in any of the answers to any of the similar problems listed in the forums or on the Unity Answers pages including:
- isolating the LoadLevel in a separate function that is called by a button press
- including a yield in the isolated function to ensure the level is loaded
function loadALevel(){
Application.LoadLevel(“startPlay”); // load the game level.
while(Application.isLoadingLevel) yield;
}
- tried wrapping the function call in a boolean to ensure that it is not being called multiple times with each button push
if(noPress){ //try this
noPress = false;
loadALevel();
}//try this
-
tried loading an empty level and then using a LoadLevelAdditive() to load the actual level
-
tried upgrading to the latest Unity
In it’s simplest form, this is how I am trying to load a new scene:
if (GUI.Button( Rect( Screen.width/2-250, Screen.height/2+30, 150, 50), “Mode A”)){
isLoading = true;
PlayerPrefs.SetString(“gameMode”,“MODEA”);
audio.clip = buttonSounds[Random.Range(0,buttonSounds.length)];
audio.Play();
Application.LoadLevel(“startPlay”); // load the game level.
}
Could there be an issue with the PlayerPrefs.SetString not having finished writing before the LoadLevel is called? Is there anything I can do about it if that’s what it is?
I am testing on a Samsung Galaxy Tab 2 (pushed on rather than emulated) and using Unity 3.5.6f4.
Thanks for any assistance. This is my first Unity game and I’m looking forward to getting it out.