void HideFrame(System.Action callback) { if (m_Frame != null) { m_Frame.SendMessageToAll("OnActivityBeginHide"); } System.Action hideAction = () => { callback.InvokeIfNotNull(); if (m_Frame != null) { m_Frame.SendMessageToAll("OnActivityEndHide"); } }; var tweener = frame != null?frame.GetAddComponent <EasyFrameAnimator>() : null; if (tweener != null) { tweener.Clear(); tweener.transitionDuration = 0.2f; tweener.fadeOut = true; tweener.fadeOutAlpha = 0; LayoutRebuilder.ForceRebuildLayoutImmediate(this.transform as RectTransform); tweener.Tween("hide", (tag) => { hideAction.InvokeIfNotNull(); }); } else { hideAction.InvokeIfNotNull(); } }
void ShowFrame(System.Action callback) { if (m_Frame != null) { m_Frame.SendMessageToAll("OnActivityBeginShow"); } System.Action showAction = () => { if (m_Frame != null) { m_Frame.transform.localPosition = GetValidLocalPositionInsideActivity(m_Frame); } callback.InvokeIfNotNull(); if (m_Frame != null) { m_Frame.SendMessageToAll("OnActivityEndShow"); } }; if (m_Frame) { m_Frame.gameObject.SetActive(true); } var tweener = frame != null?frame.GetAddComponent <EasyFrameAnimator>() : null; if (tweener != null) { tweener.Clear(); tweener.transitionDuration = 0.2f; tweener.scaleIn = true; tweener.scaleInScale = 0; tweener.fadeIn = true; tweener.fadeInAlpha = 0; LayoutRebuilder.ForceRebuildLayoutImmediate(this.transform as RectTransform); tweener.Tween("show", (tag) => { showAction.InvokeIfNotNull(); }); if (m_Frame != null) { m_Frame.transform.localPosition = GetValidLocalPositionInsideActivity(m_Frame); } } else { showAction.InvokeIfNotNull(); } }
public virtual void Transition(bool show, float attenuation, float animationDuration, float delay = 0, System.Action callback = null) { attenuation = Mathf.Clamp01(attenuation); if (gameObject != null && isShow != show) { gameObject.SetActive(true); isShow = show; //var inverseTargetValue = show ? 0f : attenuation; var targetValue = show ? attenuation : 0f; var currentValue = Mathf.Clamp01(rectTransform.localScale.y); TweenManager.EndTween(tweenId); tweenId = TweenManager.TweenFloat((value) => { //Update Color and Scale if (gameObject != null) { if (canvasGroup != null) { canvasGroup.alpha = value; } if (rectTransform != null) { rectTransform.localScale = new Vector3(rectTransform.localScale.x, value, rectTransform.localScale.z); } } }, currentValue, targetValue, animationDuration, 0, () => { tweenId = -1; if (gameObject != null && !isShow) { gameObject.SetActive(false); } callback.InvokeIfNotNull(); }); } else { isShow = show; callback.InvokeIfNotNull(); } }
public virtual void TransitionPingPong(float animationDuration, float attenuation, float pingPongDelay, System.Action callback = null) { if (!isAnimating) { if (isShow) { Transition(false, attenuation, animationDuration, 0f, callback); } else { Transition(true, attenuation, animationDuration, 0f, () => { Transition(false, attenuation, animationDuration, pingPongDelay, callback); }); } } else { callback.InvokeIfNotNull(); } }