Example #1
0
 protected virtual void Start()
 {
     _started = true;
     CheckCanvasAndGraphicsRaycaster();
     if (Application.isPlaying && enabled && gameObject.activeSelf && gameObject.activeInHierarchy)
     {
         CheckFocus(TweenContainerUtils.GetContainerVisibilityInHierarchy(this.gameObject), false);
     }
 }
Example #2
0
 protected virtual void OnEnable()
 {
     if (Application.isPlaying && enabled && gameObject.activeSelf && gameObject.activeInHierarchy)
     {
         RegisterEvents();
         if (_started)
         {
             CheckFocus(TweenContainerUtils.GetContainerVisibilityInHierarchy(this.gameObject));
         }
     }
     else if (!Application.isPlaying)
     {
         CheckCanvasAndGraphicsRaycaster();
     }
 }
Example #3
0
        protected virtual void CheckFocus(PanelStateEnum p_panelState, bool p_ignoreChildrenFocus)
        {
            if (p_panelState == PanelStateEnum.Opening || p_panelState == PanelStateEnum.Opened)
            {
                FocusGroup v_currentFocus          = FocusGroup.GetFocus();
                bool       v_canIgnoreCurrentFocus = p_ignoreChildrenFocus || v_currentFocus == null || !TweenContainerUtils.IsChildObject(this.gameObject, v_currentFocus.gameObject, false);
                if (v_canIgnoreCurrentFocus)
                {
                    FocusGroup.SetFocus(this);
                }
                else
                {
                    //Find index to add self to Focus (Index after your last children)
                    int v_indexToAddThis = 0;
                    FocusGroup.FocusOrder.RemoveChecking(this);
                    for (int i = 0; i < FocusGroup.FocusOrder.Count; i++)
                    {
                        FocusGroup v_container           = FocusGroup.FocusOrder[i];
                        bool       v_isChildrenContainer = v_container != null && TweenContainerUtils.IsChildObject(this.gameObject, v_container.gameObject, false);
                        if (v_isChildrenContainer)
                        {
                            v_indexToAddThis = i + 1;
                        }
                    }
                    FocusGroup.FocusOrder.Insert(v_indexToAddThis, this);
                }
                if (FullScreenRendering)
                {
                    FocusGroup.CorrectFullScreenRendering(p_panelState == PanelStateEnum.Opening);
                }
            }
            else if (p_panelState == PanelStateEnum.Closing || p_panelState == PanelStateEnum.Closed)
            {
                if (FullScreenRendering)
                {
                    FocusGroup.CorrectFullScreenRendering(p_panelState == PanelStateEnum.Closing);
                }
                FocusGroup.RemoveFocus(this);

                if (p_panelState == PanelStateEnum.Closed)
                {
                    //set Renderer To False After Remove
                    SetCanvasEnabled(false);
                }
            }
        }
Example #4
0
 //If Any Parent or Self contain Focus, Or Focus equal null and panel is Opened or GameObject is Active
 public static bool IsUnderFocus(GameObject p_object)
 {
     if (p_object != null)
     {
         FocusGroup     v_focus      = FocusGroup.GetFocus();
         PanelStateEnum v_panelState = v_focus == null ? PanelStateEnum.Opened : TweenContainerUtils.GetContainerVisibility(v_focus.gameObject);
         if (v_panelState == PanelStateEnum.Opened && (FocusGroup.GetDirectFocusGroupComponent(p_object) == v_focus))
         {
             return(true);
         }
     }
     return(false);
 }