Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MenuSystem : MonoBehaviour {
public GameObject menuCanvas;
private Animator anim;
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);
anim = GetComponent<Animator> ();
/* START BUTTON */
startBtn.onClick.AddListener (() => {
Debug.Log ("Start Game");
// Remove the start button
MainMenu.SetActive(false);
// Start the game
anim.SetTrigger("StartGame");
});// start button
optionBtn.onClick.AddListener(() => {
Debug.Log ("Go to Options");
// Remove the start button
MainMenu.SetActive(false);
//Trigger Options Animation
anim.SetTrigger("GoToOptions");
// Options Fades In
OptionsMenu.SetActive (true);
});// options start
/* 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;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment