- Home /
Script problem
Hi guys, I am learning how to use Unity and creating a simple Menu with START and QUIT but I am having a problem to load the scene. I have the message "The referenced script on this Behaviour (Game Object 'MainMenu') is missing!" Some advice, pls? My Unity is 2018.1.1f1 Thanks.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour {
public void PlayGame ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
public void QuitGame ()
{
Debug.Log("QUIT!");
Application.Quit();
}
}
Answer by faridphenom · Jul 27, 2018 at 09:01 PM
Hi there, you must detach the script to game object that you want to do something. if you have a game object named "Main Menu" you must drag & drop the script to its inspector Or if you want that the start or quit button works you can add the script to OnClick event for them. click on plus sign and in first section from dropdown use runtime only then choose gameobject with your script, then from second dropdown find your script and the function for that button.