using UnityEngine; using System.Collections; public class InstructionsHomeButtonHandler : MonoBehaviour { private NGUIMenuScript hNGUIMenuScript; private InGameScriptCS hInGameScriptCS; public UISprite Backgroung; public static bool FirstPlay { get { if (GameObject.Find("InfinitelyTraining")) { return true; } if (!PlayerPrefs.HasKey("FirstPlay")) { return false; } return PlayerPrefs.GetInt("FirstPlay", 1) == 1; } set { PlayerPrefs.SetInt("FirstPlay",value?1:0); PlayerPrefs.Save(); } } void Start() { hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript)); hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS)); } void Update() { Backgroung.gameObject.SetActive(!FirstPlay); } void OnClick() { //hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.MainMenu);//show the main menu //NGUITools.SetActive(this.transform.parent.gameObject, false);//hide the current menu if (!FirstPlay) { hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.MainMenuNew);//show the main menu NGUITools.SetActive(this.transform.parent.gameObject, false);//hide the current menu Debug.LogWarning("HERE"); } else { Debug.LogWarning("HERE"); FirstPlay = false; hInGameScriptCS.launchGame(); //start the gameplay hNGUIMenuScript.NGUIMenuScriptEnabled(false);//turn off the NGUI Menu Script (to improve performance) NGUITools.SetActive(this.transform.parent.gameObject, false);//close/ disable the current menu } } }