Created
October 11, 2016 00:05
-
-
Save ahmadnaser/73f54fb7ad8fe8254d76335e7535eecf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ActivateOptionsMenu(){ | |
RectTransform Canvas = GameObject.Find ("OptionsCanvas").GetComponent<RectTransform> (); | |
if (Canvas != null) { | |
RectTransform[] recs = Canvas.GetComponentsInChildren<RectTransform> (true); | |
int Count = 0; | |
int NumOfElements = 2; | |
foreach (RectTransform r in recs) { | |
if (r.gameObject.name == "Overly") { | |
Overly = r.gameObject; | |
Count++; | |
} | |
if (r.gameObject.name == "OptionsPanel") { | |
OptionsPanel = r.gameObject; | |
Count++; | |
} | |
if (Count == NumOfElements) { | |
break; | |
} | |
} | |
UnityEngine.UI.Button OptionsButton = GameObject.Find ("OptionsButton").GetComponent<UnityEngine.UI.Button> (); | |
if (OptionsButton != null) { | |
OptionsButton.onClick.AddListener (ShowOptionsMenu); | |
} | |
} | |
} | |
public void ShowOptionsMenu(){ | |
Overly.gameObject.SetActive (true); | |
OptionsPanel.gameObject.SetActive (true); | |
} | |
//usage | |
MZGeneral.Instance.ActivateOptionsMenu (); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment