private void StartAlphaTween(float targetAlpha, float duration, TweenEasing easing)
        {
            if (this.m_Image == null)
            {
                return;
            }

            // Check if currently transitioning
            if (this.m_Transitioning)
            {
                this.m_FloatTweenRunner.StopTween();
            }

            if (duration == 0f || !Application.isPlaying)
            {
                this.SetAlpha(targetAlpha);
            }
            else
            {
                this.m_Transitioning = true;

                var floatTween = new FloatTween {
                    duration = duration, startFloat = this.m_Image.canvasRenderer.GetAlpha(), targetFloat = targetAlpha
                };
                floatTween.AddOnChangedCallback(SetAlpha);
                floatTween.ignoreTimeScale = true;
                floatTween.easing          = easing;
                floatTween.AddOnFinishCallback(OnTweenFinished);

                this.m_FloatTweenRunner.StartTween(floatTween);
            }
        }
Пример #2
0
        public void SetProgress(float percent)
        {
            float      targetAmount = percent;
            FloatTween floatTween   = new FloatTween {
                duration = this.Duration, startFloat = this.imageComponent.fillAmount, targetFloat = targetAmount
            };

            floatTween.AddOnChangedCallback(SetFillAmount);
            floatTween.AddOnFinishCallback(OnTweenFinished);
            floatTween.ignoreTimeScale = true;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
        /// <summary>
        /// Starts a alpha tween on the tooltip.
        /// </summary>
        /// <param name="targetAlpha">Target alpha.</param>
        public void StartAlphaTween(float targetAlpha, float duration)
        {
            var floatTween = new FloatTween {
                duration = duration, startFloat = this.m_CanvasGroup.alpha, targetFloat = targetAlpha
            };

            floatTween.AddOnChangedCallback(SetAlpha);
            floatTween.AddOnFinishCallback(OnTweenFinished);
            floatTween.ignoreTimeScale = true;
            floatTween.easing          = this.m_TransitionEasing;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
        /// <summary>
        /// Starts alpha tween.
        /// </summary>
        /// <param name="targetAlpha">Target alpha.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="ignoreTimeScale">If set to <c>true</c> ignore time scale.</param>
        public void StartAlphaTween(float targetAlpha, float duration, bool ignoreTimeScale)
        {
            if (this.m_CanvasGroup == null)
            {
                return;
            }

            var floatTween = new FloatTween {
                duration = duration, startFloat = this.m_CanvasGroup.alpha, targetFloat = targetAlpha
            };

            floatTween.AddOnChangedCallback(SetCanvasAlpha);
            floatTween.AddOnFinishCallback(OnHideTweenFinished);
            floatTween.ignoreTimeScale = ignoreTimeScale;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Пример #5
0
        protected void StartTween(float targetFloat, float duration)
        {
            if (this.imageComponent == null)
            {
                return;
            }

            var floatTween = new FloatTween {
                duration = duration, startFloat = this.imageComponent.fillAmount, targetFloat = targetFloat
            };

            floatTween.AddOnChangedCallback(SetFillAmount);
            floatTween.AddOnFinishCallback(OnTweenFinished);
            floatTween.ignoreTimeScale = true;
            floatTween.easing          = this.Easing;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Пример #6
0
        /// <summary>
        /// Starts alpha tween.
        /// </summary>
        /// <param name="targetAlpha">Target alpha.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="easing">Easing.</param>
        /// <param name="ignoreTimeScale">If set to <c>true</c> ignore time scale.</param>
        /// <param name="callback">Event to be called on transition finish.</param>
        public void StartAlphaTween(float targetAlpha, float duration, TweenEasing easing, bool ignoreTimeScale, Events.UnityAction callback)
        {
            if (this.m_CanvasGroup == null)
            {
                return;
            }

            // Start the tween
            var floatTween = new FloatTween {
                duration = duration, startFloat = this.m_CanvasGroup.alpha, targetFloat = targetAlpha
            };

            floatTween.AddOnChangedCallback(SetCanvasAlpha);
            floatTween.AddOnFinishCallback(callback);
            floatTween.ignoreTimeScale = ignoreTimeScale;
            floatTween.easing          = easing;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Пример #7
0
        public void StartDemoTween()
        {
            if ((this.m_Type == Type.Normal && this.m_TargetImage == null) || (this.m_Type == Type.Masked && this.m_TargetTransform == null))
            {
                return;
            }

            float targetAmount = (this.m_FillAmount > 0.5f) ? 0f : 1f;

            FloatTween floatTween = new FloatTween {
                duration = this.m_Duration, startFloat = this.m_FillAmount, targetFloat = targetAmount
            };

            floatTween.AddOnChangedCallback(SetFillAmount);
            floatTween.AddOnFinishCallback(OnTweenFinished);
            floatTween.ignoreTimeScale = true;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Пример #8
0
        public void StartDemoTween()
        {
            if (this.imageComponent == null)
            {
                return;
            }

            float targetAmount = (this.imageComponent.fillAmount > 0.5f) ? 0f : 1f;

            FloatTween floatTween = new FloatTween {
                duration = this.Duration, startFloat = this.imageComponent.fillAmount, targetFloat = targetAmount
            };

            floatTween.AddOnChangedCallback(SetFillAmount);
            floatTween.AddOnFinishCallback(OnTweenFinished);
            floatTween.ignoreTimeScale = true;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Пример #9
0
        public void StartDemoTween()
        {
            if (this.bar == null)
            {
                return;
            }

            float pct          = (float)this.bar.value / (float)this.bar.maxValue;
            float targetAmount = (pct > 0.5f) ? 0f : 1f;

            FloatTween floatTween = new FloatTween {
                duration = this.duration, startFloat = pct, targetFloat = targetAmount
            };

            floatTween.AddOnChangedCallback(SetFillAmount);
            floatTween.AddOnFinishCallback(OnTweenFinished);
            floatTween.ignoreTimeScale = true;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Пример #10
0
        protected void Start()
        {
            if (this.imageComponent != null)
            {
                this.imageComponent.fillAmount = 0f;
            }

            if (this.textComponent != null)
            {
                this.textComponent.text = "0%";
            }

            var floatTween = new FloatTween {
                duration = this.Duration, startFloat = 0f, targetFloat = 1f
            };

            floatTween.AddOnChangedCallback(SetFillAmount);
            floatTween.AddOnFinishCallback(OnTweenFinished);
            floatTween.ignoreTimeScale = true;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Пример #11
0
        /// <summary>
        /// Tweens the list alpha.
        /// </summary>
        /// <param name="targetAlpha">Target alpha.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="ignoreTimeScale">If set to <c>true</c> ignore time scale.</param>
        private void TweenListAlpha(float targetAlpha, float duration, bool ignoreTimeScale)
        {
            if (this.m_ListCanvasGroup == null)
            {
                return;
            }

            float currentAlpha = this.m_ListCanvasGroup.alpha;

            if (currentAlpha.Equals(targetAlpha))
            {
                return;
            }

            var floatTween = new FloatTween {
                duration = duration, startFloat = currentAlpha, targetFloat = targetAlpha
            };

            floatTween.AddOnChangedCallback(SetListAlpha);
            floatTween.AddOnFinishCallback(OnListTweenFinished);
            floatTween.ignoreTimeScale = ignoreTimeScale;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Пример #12
0
        /// <summary>
        /// Transition the scene out.
        /// </summary>
        /// <param name="transition">The transition.</param>
        /// <param name="duration">The transition duration.</param>
        /// <param name="easing">The transition easing.</param>
        public void TransitionOut(Transition transition, float duration, TweenEasing easing)
        {
            // Make sure the scene is active and enabled
            if (!this.isActiveAndEnabled || !this.gameObject.activeInHierarchy)
            {
                return;
            }

            if (this.m_CanvasGroup == null)
            {
                return;
            }

            // If no transition is used
            if (transition == Transition.None)
            {
                this.Deactivate();
                return;
            }

            // If the transition is animation
            if (transition == Transition.Animation)
            {
                this.TriggerAnimation(this.m_AnimateOutTrigger);
                return;
            }

            // Make the scene non interactable
            //this.m_CanvasGroup.interactable = false;
            //this.m_CanvasGroup.blocksRaycasts = false;

            // Prepare some variable
            Vector2 rectSize = this.rectTransform.rect.size;

            // Prepare the rect transform
            if (transition == Transition.SlideFromLeft || transition == Transition.SlideFromRight || transition == Transition.SlideFromTop || transition == Transition.SlideFromBottom)
            {
                // Anchor and pivot top left
                this.rectTransform.pivot            = new Vector2(0f, 1f);
                this.rectTransform.anchorMin        = new Vector2(0f, 1f);
                this.rectTransform.anchorMax        = new Vector2(0f, 1f);
                this.rectTransform.sizeDelta        = rectSize;
                this.rectTransform.anchoredPosition = new Vector2(0f, 0f);
            }

            // Prepare the tween
            FloatTween floatTween = new FloatTween();

            floatTween.duration = duration;

            switch (transition)
            {
            case Transition.CrossFade:
                this.m_CanvasGroup.alpha = 1f;
                // Start the tween
                floatTween.startFloat  = this.m_CanvasGroup.alpha;
                floatTween.targetFloat = 0f;
                floatTween.AddOnChangedCallback(SetCanvasAlpha);
                break;

            case Transition.SlideFromRight:
                // Start the tween
                floatTween.startFloat  = 0f;
                floatTween.targetFloat = (rectSize.x * -1f);
                floatTween.AddOnChangedCallback(SetPositionX);
                break;

            case Transition.SlideFromLeft:
                // Start the tween
                floatTween.startFloat  = 0f;
                floatTween.targetFloat = rectSize.x;
                floatTween.AddOnChangedCallback(SetPositionX);
                break;

            case Transition.SlideFromBottom:
                // Start the tween
                floatTween.startFloat  = 0f;
                floatTween.targetFloat = rectSize.y;
                floatTween.AddOnChangedCallback(SetPositionY);
                break;

            case Transition.SlideFromTop:
                // Start the tween
                floatTween.startFloat  = 0f;
                floatTween.targetFloat = (rectSize.y * -1f);
                floatTween.AddOnChangedCallback(SetPositionY);
                break;
            }

            // Start the transition
            floatTween.AddOnFinishCallback(OnTransitionOut);
            floatTween.ignoreTimeScale = true;
            floatTween.easing          = easing;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }