public static PanelStateEnum GetContainerVisibilityInHierarchy(GameObject p_object)
 {
     if (p_object != null)
     {
         if (!p_object.activeInHierarchy)
         {
             return(PanelStateEnum.Closed);
         }
         else
         {
             TweenContainer[] v_componentsInParent = p_object.GetComponentsInParent <TweenContainer>();
             PanelStateEnum   v_return             = PanelStateEnum.Opened;
             foreach (TweenContainer v_cont in v_componentsInParent)
             {
                 if (v_cont != null && v_cont.enabled && (v_cont.PanelState == PanelStateEnum.Closed || v_cont.PanelState == PanelStateEnum.Closing))
                 {
                     v_return = v_cont.PanelState;
                 }
             }
             if (v_return != PanelStateEnum.Closed && v_return != PanelStateEnum.Closing)
             {
                 v_return = GetContainerVisibility(p_object);
             }
             return(v_return);
         }
     }
     return(PanelStateEnum.Closed);
 }
 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;
             }
         }
     }
 }
 protected virtual void OnPanelStateChanged(PanelStateEnum p_panelState)
 {
     if (p_panelState == PanelStateEnum.Opening || p_panelState == PanelStateEnum.Opened || p_panelState == PanelStateEnum.Closing)
     {
         CheckFocus(p_panelState);
     }
     else
     {
         List <object> v_parameters = new List <object>();
         v_parameters.Add(p_panelState);
         GlobalScheduler.CallFunction(this.gameObject, new Delegates.FunctionPointer <PanelStateEnum>(CheckFocus), v_parameters, 0.1f, true);
     }
 }
 //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);
 }
	protected virtual void OnPanelStateChanged(PanelStateEnum p_panelState)
	{
		if(p_panelState == PanelStateEnum.Opening || p_panelState == PanelStateEnum.Opened || p_panelState == PanelStateEnum.Closing)
		{
			CheckFocus(p_panelState);
		}
		else
		{
			List<object> v_parameters = new List<object>();
			v_parameters.Add(p_panelState);
			GlobalScheduler.CallFunction(this.gameObject, new Delegates.FunctionPointer<PanelStateEnum>(CheckFocus), v_parameters, 0.1f, true);
		}
	}
	protected virtual void OnPanelStateChanged(PanelStateEnum p_panelState)
	{
		if(enabled && gameObject.activeInHierarchy && gameObject.activeSelf)
		{
			foreach(ClipPerContainerState v_struct in ClipsPerStates)
			{
				if(v_struct != null && v_struct.PanelState == p_panelState)
				{
					Clip = v_struct.Clip;
					Play();
				}
			}
		}
	}
 private void CorrectPanelState(bool p_callLogic)
 {
     if (_panelState != m_panelState)
     {
         if (p_callLogic)
         {
             ForceSetPanelStateValue(_panelState, true);
         }
         else
         {
             m_panelState = _panelState;
         }
     }
 }
Exemple #8
0
 protected virtual void OnPanelStateChanged(PanelStateEnum p_panelState)
 {
     if (enabled && gameObject.activeInHierarchy && gameObject.activeSelf)
     {
         foreach (ClipPerContainerState v_struct in ClipsPerStates)
         {
             if (v_struct != null && v_struct.PanelState == p_panelState)
             {
                 Clip = v_struct.Clip;
                 Play();
             }
         }
     }
 }
 protected virtual void CallEventsInternal(PanelStateEnum p_panelState)
 {
     if (p_panelState == PanelStateEnum.Opened)
     {
         if (OnOpened != null)
         {
             OnOpened();
         }
         if (OnOpenedCallBack != null)
         {
             OnOpenedCallBack.Invoke();
         }
     }
     else if (p_panelState == PanelStateEnum.Closed)
     {
         if (OnClosed != null)
         {
             OnClosed();
         }
         if (OnClosedCallBack != null)
         {
             OnClosedCallBack.Invoke();
         }
     }
     else if (p_panelState == PanelStateEnum.Opening)
     {
         if (OnOpening != null)
         {
             OnOpening();
         }
         if (OnOpeningCallBack != null)
         {
             OnOpeningCallBack.Invoke();
         }
     }
     else if (p_panelState == PanelStateEnum.Closing)
     {
         if (OnClosing != null)
         {
             OnClosing();
         }
         if (OnClosingCallBack != null)
         {
             OnClosingCallBack.Invoke();
         }
     }
 }
    protected bool CheckIfStateWillChange(PanelStateEnum p_value)
    {
        bool v_return = m_panelState != p_value? true : false;

        /*if(RestartOption == RestartEnum.DontRestartIfRunning)
         * {
         *      if(m_panelState == PanelStateEnum.Closing || m_panelState == PanelStateEnum.Opening)
         *              v_return = false;
         * }*/
        if ((m_panelState == PanelStateEnum.Closed && p_value == PanelStateEnum.Closing) ||
            (m_panelState == PanelStateEnum.Opened && p_value == PanelStateEnum.Opening))
        {
            v_return = false;
        }

        return(v_return);
    }
Exemple #11
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);
                }
            }
        }
Exemple #12
0
 protected virtual void OnPanelStateChanged(PanelStateEnum p_panelState)
 {
     if ((!enabled || !gameObject.activeSelf || !gameObject.activeInHierarchy) && (p_panelState == PanelStateEnum.Opening || p_panelState == PanelStateEnum.Opened))
     {
         p_panelState = PanelStateEnum.Closing;
     }
     if (p_panelState == PanelStateEnum.Opening || p_panelState == PanelStateEnum.Opened || p_panelState == PanelStateEnum.Closing)
     {
         CheckFocus(p_panelState);
     }
     else
     {
         List <object> v_parameters = new List <object>();
         v_parameters.Add(p_panelState);
         Kyub.DelayedFunctionUtils.CallFunction(new System.Action <PanelStateEnum>(CheckFocus), v_parameters.ToArray(), 0.1f);
     }
 }
    public void ForceSetPanelStateValue(PanelStateEnum p_value, bool p_updateEffect, bool p_underDisableOrEnable = false)
    {
        if (Scheduler == null || !EnableScheduler)
        {
            if (p_value == PanelStateEnum.Opening)
            {
                p_value = PanelStateEnum.Opened;
            }
            if (p_value == PanelStateEnum.Closing)
            {
                p_value = PanelStateEnum.Closed;
            }
        }
        bool p_changed = CheckIfStateWillChange(p_value);

        m_panelState = p_value;
        _panelState  = m_panelState;

        if (p_changed)
        {
            if (CloseSpecialAction != CloseSpecialActionEnum.Deactivate || m_panelState != PanelStateEnum.Closed)
            {
                if (!p_underDisableOrEnable)
                {
                    SetActiveAndEnable(true, true);
                }
                if (Application.isPlaying)
                {
                    gameObject.SendMessage("OnPanelStateChanged", m_panelState, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
        if (Application.isPlaying && (CloseSpecialAction != CloseSpecialActionEnum.Deactivate || m_panelState != PanelStateEnum.Closed))
        {
            gameObject.SendMessage("CallEventsInternal", m_panelState, SendMessageOptions.DontRequireReceiver);
        }
        else
        {
            CallEventsInternal(m_panelState);
        }

        if (p_updateEffect)
        {
            UpdateEffect();
        }

        //Used to Prevent Bugs while activating
        if (p_underDisableOrEnable)
        {
            if (Application.isPlaying && (CloseSpecialAction != CloseSpecialActionEnum.Deactivate || m_panelState != PanelStateEnum.Closed))
            {
                gameObject.SendMessage("CallControlSpecialAction", SendMessageOptions.DontRequireReceiver);
                gameObject.SendMessage("UpdateObjectsToShowOrHideByState", SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                CallControlSpecialAction();
                UpdateObjectsToShowOrHideByState();
            }
        }
        else
        {
            CallControlSpecialAction();
            UpdateObjectsToShowOrHideByState();
            if (!gameObject.activeSelf)
            {
                if (Application.isPlaying)
                {
                    GlobalScheduler.CallFunction(this.gameObject, new Delegates.FunctionPointer(CheckNeedActivate), 0.01f, true);
                }
            }
        }
        if (!Application.isPlaying)
        {
            ControlSpecialAction();
            CheckNeedActivate();
        }
    }
 public void ForceSetPanelStateValue(PanelStateEnum p_value)
 {
     ForceSetPanelStateValue(p_value, true);
 }
	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;
			}
		}
	}
Exemple #16
0
 protected void CheckFocus(PanelStateEnum p_panelState)
 {
     CheckFocus(p_panelState, true);
 }