static void ShowUI(GameObject uiObject, UIElementHolder uiObjectC, bool needsInput, bool tryRepeat) { //set active so we can call coroutines on it // instance.gameObject.SetActive(true); instance.StartCoroutine(_ShowUI(uiObject, uiObjectC, needsInput, tryRepeat)); }
// public static event System.Action<UIElementHolder> onUIShow; static IEnumerator _ShowUI(GameObject uiObject, UIElementHolder uiObjectC, bool needsInput, bool tryRepeat) { if (needsInput) { inputModule.gameObject.SetActive(true); } uiObject.SetActive(true); // for some reason, layout groups need to be enabled and disabled a few times // to show correctly if (needsInput) { instance.shownUIsWithInput.Add(uiObject); // inputModule.gameObject.SetActive(true); } if (tryRepeat) { yield return(null); uiObject.SetActive(false); yield return(null); uiObject.SetActive(true); yield return(null); uiObject.SetActive(false); yield return(null); uiObject.SetActive(true); } // else { // instance.gameObject.SetActive(false); // } // Debug.LogError("adding callbacks"); // foreach (var d in gameManager.GetUISelectInvocations()) { if (onUISelect != null) { foreach (var d in GetUISelectInvocations()) { uiObjectC.onSelectEvent += (System.Action <GameObject[], object[]>)d; } } // foreach (var d in gameManager.GetUISubmitInvocations()) { if (onUISubmit != null) { foreach (var d in GetUISubmitInvocations()) { uiObjectC.onSubmitEvent += (System.Action <GameObject[], object[], Vector2Int>)d; } } }
public static void ShowUI(UIElementHolder uiObject, bool needsInput, bool tryRepeat) { ShowUI(GetUIObj(uiObject), uiObject, needsInput, tryRepeat); // Debug.LogError("adding callbacks"); // foreach (var d in gameManager.GetUISelectInvocations()) { // uiObject.onSelectEvent += (System.Action<GameObject[], object[]>)d; // } // foreach (var d in gameManager.GetUISubmitInvocations()) { // uiObject.onSubmitEvent += (System.Action<GameObject[], object[]>)d; // } // if (onUIShow != null) { // onUIShow(uiObject); // } }
public static void HideUI(UIElementHolder uiObject) { // GameObject objToUse = GetUIObj(uiObject); HideUI(GetUIObj(uiObject)); uiObject.RemoveAllEvents(); }
static GameObject GetUIObj(UIElementHolder uiObject) { return(uiObject.baseObject != null ? uiObject.baseObject : uiObject.gameObject); }