My function just doesn't do anything when I put it in onclick is there a problem with my script?
using UnityEngine;
using System.Collections;
public class troll : MonoBehaviour {
public void ll0 () {
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.LoadLevel(0)
#endif
}
}
Answer by Kimi073 · Nov 20, 2015 at 09:52 AM
I don't know what exactly are you trying to do, but as what I'm seeing are you trying to start the game from code? or load a specific level? or anything else that you may want?
In the most overall case, you may haven't added you scene into the Build Setting yet. So this is the solution for this:
First open your want-to-load scene Secondly choose File in the bar as in the picture (sorry don't know what is this bar called in English) Choose Build Setting... in the drop down list In the Build Setting Window, you should be able to see the "Add current" button
Click it to add the current scene In the script, you should put the name of the scene you just added in to the quotation mark like this:
//Your above code
Application.LoadLevel(" your scene name in here ");
// You below code
That's the solution for what I assume. If isn't, just take this as one of your experience :3 Good luck!
Your answer
![](https://koobas.hobune.stream/wayback/20220612045724im_/https://answers.unity.com/themes/thub/images/avi.jpg)