static void AddUIToStack(UIWithInput ui) { if (uiStack.Count == 0) { UIInput.MarkAllSelectionAxesOccupied(); inputModule.gameObject.SetActive(true); } else { if (uiStack.Contains(ui)) { Debug.LogError("Adding duplicate ui: " + ui.name); } for (int i = 0; i < uiStack.Count; i++) { uiStack[i].SetSelectablesActive(false); if (i == uiStack.Count - 1) { UIInput.MarkActionsUnoccupied(uiStack[i].GetUsedActions()); } } } UIInput.MarkActionsOccupied(ui.GetUsedActions()); ui.SetSelectablesActive(true); uiStack.Add(ui); }
static void RemoveUIFromStack(UIWithInput ui) { bool wasTop = UIIsLastInStack(ui); uiStack.Remove(ui); if (wasTop) { UIInput.MarkActionsUnoccupied(ui.GetUsedActions()); if (uiStack.Count > 0) { UIWithInput newTop = uiStack[uiStack.Count - 1]; UIInput.MarkActionsOccupied(newTop.GetUsedActions()); newTop.SetSelectablesActive(true); } } }
// public static HashSet<UIWithInput> shownUIsWithInput = new HashSet<UIWithInput>(); public static void ShowUIComponent(UIComponent uiObject, float fadeInTime, float duration, float fadeOutTime) { if (uiObject.canvas == null) { Debug.LogWarning(uiObject.name + " doesnt have a canvas component, cant fully enable"); // return; } else { int id = uiObject.GetInstanceID(); if (StopCoroutinesIfRunning(fadeOutCoroutines, id)) { uiObject.canvas.enabled = false; } if (uiObject.canvas.enabled) { // Debug.LogWarning(uiObject.name + " is already open..."); return; } // Debug.Log(uiObject.name + " Setting canvas enebaled true"); uiObject.canvas.enabled = true; } // if (uiObject.canvas != null) bool isActiveInHiearchy = TransformIsActiveInUICanvas(uiObject.baseObject.transform); if (!isActiveInHiearchy) { Debug.LogWarning(uiObject.name + " is not active in hiearchy..."); } UIWithInput asInputTaker = uiObject as UIWithInput; if (isActiveInHiearchy) { if (asInputTaker != null) { AddUIToStack(asInputTaker); // inputModule.gameObject.SetActive(true); // shownUIsWithInput.Add(asInputTaker); } } // uiObject.baseObject.SetActive(true); FadeInComponent(uiObject, fadeInTime, duration, fadeOutTime, isActiveInHiearchy); if (isActiveInHiearchy) { if (asInputTaker != null) { asInputTaker.SetSelectablesActive(true); if (onAnyUISelect != null) { foreach (var d in onAnyUISelect.GetInvocationList()) { asInputTaker.SubscribeToSelectEvent((Action <UISelectable, object[]>)d); } } if (onAnyUISubmit != null) { foreach (var d in onAnyUISubmit.GetInvocationList()) { asInputTaker.SubscribeToActionEvent((Action <UISelectable, object[], Vector2Int>)d); } } } } }