Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MenuSystem : MonoBehaviour {
public GameObject menuCanvas;
private Transform SubtitleTrue;
private Transform SubtitleFalse;
// Use this for initialization
void Start () {
Button startBtn = menuCanvas.transform.Find ("Main Menu").Find ("Start Game").GetComponent<Button> ();
Button optionBtn = menuCanvas.transform.Find ("Main Menu").Find ("Options").GetComponent<Button> ();
Button optionStartBtn = menuCanvas.transform.Find ("Options Menu").Find ("Start Game").GetComponent<Button> ();
GameObject MainMenu = GameObject.Find("Main Menu");
GameObject OptionsMenu = GameObject.Find("Options Menu");
OptionsMenu.SetActive (false);
/* START BUTTON */
startBtn.onClick.AddListener (() => {
Debug.Log ("Start Game");
// Remove the start button
MainMenu.SetActive(false);
// Start the game
});// start button
optionBtn.onClick.AddListener(() => {
Debug.Log ("Go to Options");
// Remove the start button
MainMenu.SetActive(false);
// go to options
menuCanvas.SetActive(false);
// Options Fades In
OptionsMenu.SetActive (true);
});// options start
optionStartBtn.onClick.AddListener (() => {
Debug.Log ("Options Start");
OptionsMenu.SetActive(false);
// Start game from options
});// options start button
/* OPTIONS MENU */
SubtitleTrue = OptionsMenu.transform.Find ("SubtitleTrue");
SubtitleFalse = OptionsMenu.transform.Find ("SubtitleFalse");
SubtitleFalse.GetComponent<Image>().enabled = false;
SubtitleTrue.GetComponent<Button> ().onClick.AddListener (() => {
// Start fading towards black.
Debug.Log ("Subtitles On");
SubtitleTrue.GetComponent<Image>().enabled = true;
SubtitleFalse.GetComponent<Image>().enabled = false;
});
SubtitleFalse.GetComponent<Button> ().onClick.AddListener (() => {
Debug.Log ("Subtitles Off");
SubtitleFalse.GetComponent<Image>().enabled = true;
SubtitleTrue.GetComponent<Image>().enabled = false;
});
}
void Update ()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.