Пример #1
0
        public void SubscribeToActionEvent(Action <UISelectable, object[], Vector2Int> callback)
        {
            // Debug.Log("Subscribing events " + name);

            if ((object)parent != null)
            {
                parent.SubscribeToActionEvent(callback);
                return;
            }
            _onAction += callback;
            onActionDelegates.Add(callback);
        }
Пример #2
0
        static void ShowPopup(bool saveSelection, UIWithInput popup, Action <UISelectable, object[], Vector2Int> onSubmit)
        {
            if (onPopupOpen != null)
            {
                onPopupOpen();
            }

            // Debug.Log("Displaying popup");

            if (saveSelection)
            {
                selectedWhenPoppedUp = UIManager.CurrentSelected();
            }

            // List<int> actions = new List<int> { settings.submitAction, settings.cancelAction };
            // List<string> hints = new List<string> { "Confirm", "Cancel" };

            // mark actions occupied if no ui open
            // if (UIManager.shownUIsWithInput.Count == 0) {
            //     // UIInput.MarkAllBaseUIInputsOccupied();
            //     UIInput.MarkActionsOccupied(actions);
            // }

            popup.SetOverrideActions(null, null);

            // Debug.Log("SHOWING POPUP");

            // UIManager.ShowUI(popup);
            UIManager.ShowUIComponent(popup, 0, 0, 0);
            popupOpen = true;

            // popup.AddActionHints(actions, hints);

            // UIManager.SetAllActiveUIsSelectableActive(false);
            popup.SubscribeToActionEvent(onSubmit);
        }
Пример #3
0
        // 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);
                        }
                    }
                }
            }
        }