- Home /
Game Crashes When Changing Scenes When Built
So, just for fun, I wanted to see how my game worked as an EXE. So I added a couple of out-of-Unity-relevant scripts to the thing and clicked "Build and Run." Everything worked fine up to the point where the game was supposed to switch to a new scene. At first, the game crashed, but after I fiddled with it slightly, now it just permanently freezes. Here are the scene-switching code snippets:
When you die, you hit space to restart Scene 0:
#pragma strict
public var restartLevel : String;
function Update(){
if(Input.GetKeyDown(KeyCode.Space)){
Application.LoadLevel(restartLevel);
}
}
When you hit the goal cube, you go to the next scene, as defined by the variable nextLevel:
#pragma strict
public var nextLevel : String;
function OnCollisionEnter(myCollision : Collision){
if(myCollision.gameObject.name == "NextLevelCube"){
Application.LoadLevel(nextLevel);
}
}
Both instances have been tried, and both have failed every time.
Maybe I'm using the wrong commands? Both scripts work like a dream in Unity itself, but whenever I build and run, they just fail miserably.
Any help would be welcome.
i had this problem on iphone 3gs but not 4, to much stuff trying to load crashed older models, i dont know how much help this is, have you tried empty scenes.
Your answer
Follow this Question
Related Questions
build error: HideFlags.DontSave with asset named PreMatLight0 1 Answer
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
How can I stop the variable values reverting to its default values after being built? 1 Answer
Help, i can't build my game..! 1 Answer
Game build taking days? 1 Answer