Пример #1
0
 public static void RemoveFocus(FocusContainer p_container)
 {
     if (p_container != null)
     {
         FocusOrder.RemoveChecking(p_container);
     }
 }
Пример #2
0
    public static FocusContainer GetFocus()
    {
        FocusOrder.RemoveNulls();
        FocusContainer v_container = FocusOrder.GetFirst();

        return(v_container);
    }
 public virtual void CheckInput(bool p_force = false)
 {
     if ((p_force || Input.GetKeyDown(KeyCode.Tab)) && FocusContainer.IsUnderFocus(this.gameObject))
     {
         StartCoroutine(ChangeInput());
     }
 }
Пример #4
0
    protected static void CorrectFullScreenRendering(bool p_isTransition)
    {
        FocusContainer v_firstFullScreenRenderingContainer  = null;
        FocusContainer v_secondFullScreenRenderingContainer = null;

        foreach (FocusContainer v_container in FocusOrder)
        {
            if (v_container != null && v_container.FullScreenRendering)
            {
                v_container.CheckCanvasAndGraphicsRaycaster();
                Canvas v_canvas = v_container.GetComponent <Canvas>();
                UnityEngine.UI.GraphicRaycaster v_graphicsRayCaster = v_container.GetComponent <UnityEngine.UI.GraphicRaycaster>();
                if (v_firstFullScreenRenderingContainer == null)
                {
                    v_firstFullScreenRenderingContainer = v_container;
                }
                else if (p_isTransition && v_firstFullScreenRenderingContainer != null && v_secondFullScreenRenderingContainer == null)
                {
                    v_secondFullScreenRenderingContainer = v_container;
                }
                if (v_graphicsRayCaster != null)
                {
                    v_graphicsRayCaster.enabled = v_firstFullScreenRenderingContainer == v_container || v_secondFullScreenRenderingContainer == v_container;
                }
                if (v_canvas != null)
                {
                    v_canvas.enabled = v_firstFullScreenRenderingContainer == v_container || v_secondFullScreenRenderingContainer == v_container;
                }
            }
        }
    }
Пример #5
0
 protected virtual void CheckFocus(PanelStateEnum p_panelState)
 {
     if (p_panelState == PanelStateEnum.Opening || p_panelState == PanelStateEnum.Opened)
     {
         FocusContainer.SetFocus(this);
         FocusContainer.CorrectFullScreenRendering(p_panelState == PanelStateEnum.Opening);
     }
     else if (p_panelState == PanelStateEnum.Closing || p_panelState == PanelStateEnum.Closed)
     {
         FocusContainer.CorrectFullScreenRendering(p_panelState == PanelStateEnum.Closing);
         FocusContainer.RemoveFocus(this);
         if (p_panelState == PanelStateEnum.Closed)
         {
             //set Renderer To False Before Remove
             Canvas v_canvas = GetComponent <Canvas>();
             UnityEngine.UI.GraphicRaycaster v_graphicsRayCaster = GetComponent <UnityEngine.UI.GraphicRaycaster>();
             if (v_graphicsRayCaster != null)
             {
                 v_graphicsRayCaster.enabled = false;
             }
             if (v_canvas != null)
             {
                 v_canvas.enabled = false;
             }
         }
     }
 }
Пример #6
0
 public static bool ContainFocus(FocusContainer p_container)
 {
     if (p_container != null && p_container == GetFocus())
     {
         return(true);
     }
     return(false);
 }
Пример #7
0
        public RecordingModel(Recording rec, Button[] utils, MacrosView ui)
        {
            this.ui     = ui;
            this.utils  = utils;
            FocusedTray = new FocusContainer(this);
            Keyframes   = new ObservableCollection <InfoTray>();

            LoadRecording(rec);
        }
Пример #8
0
 public static bool ParentContainFocus(GameObject p_child)
 {
     if (p_child != null)
     {
         FocusContainer v_directParentFocus = GetDirectFocusContainerComponent(p_child);
         return(ContainFocus(v_directParentFocus));
     }
     return(false);
 }
Пример #9
0
 public void LoadRecording(Recording rec)
 {
     Keyframes.Clear();
     FocusedTray = new FocusContainer(this);
     foreach (var kf in rec.Keyframes)
     {
         var tray = InfoTray.BuildNew(kf, FocusedTray);
         Keyframes.Add(tray);
     }
 }
Пример #10
0
 protected virtual void HandleOnGlobalPress(bool p_pressed)
 {
     if (KiltUICamera.currentTouch != null && p_pressed)
     {
         FocusContainer v_directParentFocus = GetDirectFocusContainerComponent(KiltUICamera.currentTouch.pressed);
         if (v_directParentFocus == this)
         {
             FocusContainer.SetFocus(this);
         }
     }
 }
Пример #11
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)
     {
         FocusContainer v_focus      = FocusContainer.GetFocus();
         PanelStateEnum v_panelState = v_focus == null? PanelStateEnum.Opened : KiltUtils.GetContainerVisibility(v_focus.gameObject);
         if (v_panelState == PanelStateEnum.Opened && (FocusContainer.GetDirectFocusContainerComponent(p_object) == v_focus))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #12
0
 public static void SetFocus(FocusContainer p_container)
 {
     if (p_container != null && GetFocus() != p_container)
     {
         FocusOrder.RemoveChecking(p_container);
         if (FocusOrder.Count > 0)
         {
             FocusOrder.Insert(0, p_container);
         }
         else
         {
             FocusOrder.Add(p_container);
         }
     }
 }
Пример #13
0
 protected void CallSend(bool p_ignoreFocus = true)
 {
     if (p_ignoreFocus || FocusContainer.IsUnderFocus(this.gameObject))
     {
         if (CanCallWhenLoadingScene || !SceneManager.IsLoading() && _currentTimeBeetweenSends <= 0)
         {
             _currentTimeBeetweenSends = TimeBeetweenSends;
             CallPauseAction();
             BeforeSend();
             if (OnSendCallback != null)
             {
                 OnSendCallback.Invoke();
             }
             Send();
         }
     }
 }
Пример #14
0
 public static FocusContainer GetDirectFocusContainerComponent(GameObject p_child)
 {
     if (p_child != null)
     {
         FocusContainer[] v_parentsFocus      = p_child.GetComponentsInParent <FocusContainer>();
         FocusContainer   v_directParentFocus = null;
         foreach (FocusContainer v_parentFocus in v_parentsFocus)
         {
             if (v_parentFocus != null && v_parentFocus.enabled)
             {
                 v_directParentFocus = v_parentFocus;
                 break;
             }
         }
         return(v_directParentFocus);
     }
     return(null);
 }
Пример #15
0
 //Only works when grabing touch inside HandleGlobalPress
 protected virtual void GrabTouch()
 {
     if (!_grabbing && KiltUICamera.currentTouch != null)
     {
         if (!OnlyShowWhenGrabTouch || KiltUICamera.currentTouch.current == null)
         {
             if (!OnlyShowWhenGrabTouch && !FocusContainer.IsUnderFocus(this.gameObject))
             {
                 return;
             }
             _grabbing       = true;
             _touchReference = KiltUICamera.currentTouch;
             if (KiltUICamera.currentTouch.current == null)
             {
                 KiltUICamera.currentTouch.current = this.gameObject;
                 KiltUICamera.currentTouch.pressed = this.gameObject;
                 KiltUICamera.currentTouch.dragged = this.gameObject;
             }
             UpdateTrail(true);
         }
     }
 }
    protected virtual IEnumerator ChangeInput()
    {
        if (!_checking)
        {
            _checking = true;
            EventSystem v_eventSystem = EventSystem.current;
            if (v_eventSystem != null)
            {
                bool       v_moveBack = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
                GameObject v_currentSelectedGameObject = v_eventSystem.currentSelectedGameObject;
                Selectable v_currentSelectedComponent  = v_currentSelectedGameObject != null?v_currentSelectedGameObject.GetComponent <Selectable>() : null;

                if (!(v_currentSelectedComponent is InputField) || !(((InputField)v_currentSelectedComponent).multiLine))
                {
                    List <Selectable> v_currentSelectables = new List <Selectable>();
                    for (int i = 0; i < Selectable.allSelectables.Count; i++)
                    {
                        Selectable v_selectableComponent = Selectable.allSelectables[i];
                        v_currentSelectables.RemoveChecking(v_selectableComponent);
                        if (v_selectableComponent != null && v_selectableComponent.navigation.mode != Navigation.Mode.None && FocusContainer.IsUnderFocus(v_selectableComponent.gameObject))
                        {
                            //Sort with SelectionUpDown Index
                            int  v_indexDown         = v_currentSelectables.IndexOf(v_selectableComponent.navigation.selectOnDown);
                            int  v_indexUp           = v_currentSelectables.IndexOf(v_selectableComponent.navigation.selectOnUp);
                            bool v_insertingComplete = false;
                            int  v_indexToInsert     = v_indexDown >= 0 && v_indexDown < v_currentSelectables.Count? v_indexDown : (v_indexUp >= 0 && v_indexUp < v_currentSelectables.Count? v_indexUp + 1 : -1);
                            if (v_indexToInsert >= 0 && v_indexToInsert < v_currentSelectables.Count + 1)
                            {
                                try
                                {
                                    v_currentSelectables.Insert(v_indexToInsert, v_selectableComponent);
                                    v_insertingComplete = true;
                                }
                                catch {}
                            }
                            if (!v_insertingComplete)
                            {
                                v_insertingComplete = true;
                                v_currentSelectables.Add(v_selectableComponent);
                            }
                        }
                    }

                    if (v_currentSelectedComponent != null)
                    {
                        int v_index = v_currentSelectables.IndexOf(v_currentSelectedComponent);
                        v_index = v_moveBack? v_index - 1 : v_index + 1;
                        v_currentSelectedComponent  = v_index >= 0 && v_index < v_currentSelectables.Count? v_currentSelectables[v_index] : null;
                        v_currentSelectedGameObject = v_currentSelectedComponent != null? v_currentSelectedComponent.gameObject : null;
                    }
                    if (v_currentSelectedComponent == null)
                    {
                        v_currentSelectedComponent  = v_moveBack? v_currentSelectables.GetLast() : v_currentSelectables.GetFirst();
                        v_currentSelectedGameObject = v_currentSelectedComponent != null? v_currentSelectedComponent.gameObject : null;
                    }

                    v_eventSystem.SetSelectedGameObject(v_currentSelectedGameObject);
                    if (v_currentSelectedComponent != null)
                    {
                        InputField v_inputfield = v_currentSelectedComponent.GetComponent <InputField>();
                        if (v_inputfield != null)
                        {
                            v_inputfield.OnPointerClick(new PointerEventData(v_eventSystem));
                        }
                        yield return(StartCoroutine(CoroutineUtil.WaitForRealSeconds(0.05f)));
                    }
                }
            }
            _checking = false;
        }
    }
Пример #17
0
	public static bool ContainFocus(FocusContainer p_container)
	{
		if(p_container != null && p_container == GetFocus())
		{
			return true;
		}
		return false;
	}
Пример #18
0
	public static void RemoveFocus(FocusContainer p_container)
	{
		if(p_container != null)
		{
			FocusOrder.RemoveChecking(p_container);
		}
	}
Пример #19
0
 protected virtual void HandleOnGlobalDrop(GameObject p_dropObject)
 {
     if (!OnlyShowWhenGrabTouch && IsGrabbing() && IsTouchReferenceEqualsCurrentTouch(KiltUICamera.currentTouch) && FocusContainer.IsUnderFocus(this.gameObject))
     {
         UpdateTrail(false);
     }
 }
Пример #20
0
	public static void SetFocus(FocusContainer p_container)
	{
		if(p_container != null && GetFocus() != p_container)
		{
			FocusOrder.RemoveChecking(p_container);
			if(FocusOrder.Count > 0)
				FocusOrder.Insert(0, p_container);
			else
				FocusOrder.Add(p_container);
		}
	}