Esempio n. 1
0
 public void SubscribeToSelectEvent(Action <UISelectable, object[]> callback)
 {
     if ((object)parent != null)
     {
         parent.SubscribeToSelectEvent(callback);
         return;
     }
     _onSelect += callback;
     onSelectdelegates.Add(callback);
 }
Esempio n. 2
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);
                        }
                    }
                }
            }
        }