Skip to content

Instantly share code, notes, and snippets.

@maxbye3
Created November 16, 2015 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxbye3/00018d4c4132bc9b95c4 to your computer and use it in GitHub Desktop.
Save maxbye3/00018d4c4132bc9b95c4 to your computer and use it in GitHub Desktop.
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