So I'm getting an error on line 19 of this script and most of the buttons are not working and I'm not sure why. As I was adding to my UI (I was working on a settings tab) I somehow managed to break most of the buttons on my main menu and I cannot figure out why. Another thing I'd like to ask is if the GameObject.Find is the proper way to do this as it seems I'm doing this a lot in my scripts and I feel like I should be less dependent on that. Thanks in advance!
using UnityEngine;
using System.Collections;
public class MainMenu : MonoBehaviour {
private GameObject settingsMenu;
private GameObject mainMenu;
private Settings settingsScript;
private GameObject mainMenuManager;
void Awake () {
settingsMenu = GameObject.Find ("SettingsMenu");
mainMenuManager = GameObject.Find ("MainMenuManager");
settingsScript = mainMenuManager.GetComponent ();
mainMenu = GameObject.Find ("MainMenu");
}
void Start () {
settingsMenu.SetActive (false);
settingsScript.enabled = false;
Time.timeScale = 1.0f;
}
public void NewGame() {
Application.LoadLevel (1);
}
public void QuitGame () {
Application.Quit ();
}
public void MainMenuSettings () {
settingsScript.enabled = true;
mainMenu.SetActive (false);
settingsMenu.SetActive (true);
}
public void GoBackToMainMenu() {
settingsMenu.SetActive (false);
mainMenu.SetActive (true);
}
}
↧