- Home /
The question is answered, right answer was accepted
crash in standalone app not in editor
hey there, i've been making a game and it's almost finished. so i added a main menu and if i compile it into a standalone app (to test out the quit button) the app says powered by unity and then there's a black screen and then it crashes. this happens on mac and windows.
here is the start script that loads the level when pressed the start button
using UnityEngine; using System.Collections;
public class Start: MonoBehaviour {
public void LoadLevel(int Index = 1)
{
Application.LoadLevel(Index = 1);
}
}
and here's the quit script that quits the application when th quit button is pressed. using UnityEngine; using System.Collections;
public class Quit : MonoBehaviour {
public void ExitApplication()
{
ExitApplication();
}
}
i've tried application.quit
but that gives the same result..... a crash
so this works in the editor but as a standalone application it crashes.
edit: i changed the start code it's this now and it still crashes
using UnityEngine;
using System.Collections;
public class Start: MonoBehaviour {
public void NextLevelButton()
{
Application.LoadLevel("game");
}
}
Take out the =1 from your LoadLevel function arguments. On that note, call it something different altogether. Perhaps its getting confused.
Are you sure it works in editor? The editor mode tends to "bypass" error, I mean it prints them on console and then manages to continue if possible. In build, a null ref tends to break the app no matter what. So check your console.
As for the method itself, the parameter is one by default and turned to 1 if else, so, kinda confusing what is happening.
Why are you using Index = 1? If you want to load level 1, just type:
Application.LoadLevel(1); or Application.LoadLevel("LevelName");
If the application is craching, then you most likely get an error in the editor...
i used the string kind but that didn't work because it said level -1 wasn't added to the build
Answer by assassins-badjas · Feb 21, 2015 at 01:10 PM
okay so i fixed it by giving the uibutton sprites a material. it loads a bit slow but it works. i'm not sure why i had to give them materials tough.
Follow this Question
Related Questions
Initialising List array for use in a custom Editor 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to fix losing System.Data.dll in Project? 2 Answers
Editing Animations crashes Unity 1 Answer