Since yesterday i am working on my Home Menu of my Game…
Theres a Button named “Button1”.
I would that when you’re clicking on this Button it’s loading a new Scene…
But… it doesn’t works, here’s the script:
using UnityEngine;
using System.Collections;
public class SwitchScene : MonoBehaviour {
void OnClick ()
{
Application.LoadLevel("LevelOne");
}
}
Can somebody help me how i have to do a button to conect scenes?
I assume you are using the new UI and Button1 has a Button-Component.
Add your script to the button. Then add a new EventListener to the button by clicking on the ‘+’ sign in the OnClick()-section of the Button-Component. Drag the GameObject where your script is on (in this case the button itself) into the appearing object field and choose your OnClick()-method from the drop-down menu that appears to the right.
If your method is not on the list you might want to make it public.
Lastly, add your “LevelOne”-scene to the build settings (File > BuildSettings) to make sure your code will work in the built game.