Exemple #1
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)
     {
         MaterialFocusGroup v_focus = MaterialFocusGroup.GetFocus();
         var v_state = v_focus == null ? true : v_focus.GetGroupVisibilityInHierarchy();
         if (v_state && (MaterialFocusGroup.GetDirectFocusGroupComponent(p_object) == v_focus))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #2
0
 protected virtual void CheckFocus(bool p_active, bool p_ignoreChildrenFocus, bool p_keepInFocusList)
 {
     if (p_active && enabled)
     {
         MaterialFocusGroup v_currentFocus = MaterialFocusGroup.GetFocus();
         bool v_canIgnoreCurrentFocus      = p_ignoreChildrenFocus || v_currentFocus == null || !MaterialFocusGroup.IsChildObject(this.gameObject, v_currentFocus.gameObject, false);
         if (v_canIgnoreCurrentFocus)
         {
             if (!MaterialFocusGroup.SetFocus(this))
             {
                 StartKeyTriggerUpdateRoutine();
             }
         }
         else
         {
             //Find index to add self to Focus (Index after your last children)
             int v_indexToAddThis = 0;
             var v_index          = MaterialFocusGroup.FocusOrder.IndexOf(this);
             if (v_index >= 0)
             {
                 MaterialFocusGroup.FocusOrder.RemoveAt(v_index);
             }
             for (int i = 0; i < MaterialFocusGroup.FocusOrder.Count; i++)
             {
                 MaterialFocusGroup v_container = MaterialFocusGroup.FocusOrder[i];
                 bool v_isChildrenContainer     = v_container != null && MaterialFocusGroup.IsChildObject(this.gameObject, v_container.gameObject, false);
                 if (v_isChildrenContainer)
                 {
                     v_indexToAddThis = i + 1;
                 }
             }
             MaterialFocusGroup.FocusOrder.Insert(v_indexToAddThis, this);
             StartKeyTriggerUpdateRoutine();
         }
     }
     else
     {
         if (!MaterialFocusGroup.RemoveFocus(this, p_keepInFocusList))
         {
             CancelKeyTriggerUpdateRoutine();
         }
     }
 }