I’m trying to follow these Unity 5 tutorials. But I’ve had some trouble.
I Scripting a play button to Open a Scene when it gets clicked.
In the video tutorial the button On Click space should look like this.
But in my Unity 5 Editor When I try to follow, Canvas has no Function
LoadOnClick.LoadScene.
And it looks like this .
create a new script called SceneLoader.cs and attach it to the canvas. Paste this in:
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneLoader : MonoBehaviour {
public void LoadSceneOnClick(int sceneNo)
{
SceneManager.LoadScene(sceneNo);
}
}
Now drag the canvas back into the OnClick listener for your button and select the LoadSceneOnClick(int) method of SceneLoader from the drop down and assign it the integer of the scene you want to load. Remember, scene numbers are zero indexed.