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);
            }
        }
Esempio n. 2
0
        /// <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.ignoreTimeScale = true;
            floatTween.easing          = this.fadeEasing;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        protected void StartTween(float startFloat, float targetFloat)
        {
            FloatTween info = new FloatTween
            {
                duration    = this.m_TransitionDuration,
                startFloat  = startFloat,
                targetFloat = targetFloat
            };

            info.AddOnChangedCallback(SetHeight);
            info.ignoreTimeScale = true;
            this.m_FloatTweenRunner.StartTween(info);
        }
Esempio n. 5
0
 private void AlphaFadeList(float duration, float start, float end)
 {
     if (!end.Equals(start))
     {
         FloatTween floatTween = default(FloatTween);
         floatTween.duration    = duration;
         floatTween.startValue  = start;
         floatTween.targetValue = end;
         FloatTween info = floatTween;
         info.AddOnChangedCallback(SetAlpha);
         info.ignoreTimeScale = true;
         m_AlphaTweenRunner.StartTween(info);
     }
 }
Esempio n. 6
0
 private void AlphaFadeList(float duration, float start, float end)
 {
     if (!end.Equals(start))
     {
         FloatTween info = new FloatTween {
             duration    = duration,
             startValue  = start,
             targetValue = end
         };
         info.AddOnChangedCallback(new UnityAction <float>(this.SetAlpha));
         info.ignoreTimeScale = true;
         this.m_AlphaTweenRunner.StartTween(info);
     }
 }
Esempio n. 7
0
        private void AlphaFadeList(float duration, float start, float end)
        {
            if (end.Equals(start))
            {
                return;
            }

            FloatTween tween = new FloatTween {
                duration = duration, startValue = start, targetValue = end
            };

            tween.AddOnChangedCallback(SetAlpha);
            tween.ignoreTimeScale = true;
            m_AlphaTweenRunner.StartTween(tween);
        }
Esempio n. 8
0
        protected void StartTween(float startFloat, float targetFloat)
        {
            float duration = (this.m_Accordion != null) ? this.m_Accordion.transitionDuration : 0.3f;

            FloatTween info = new FloatTween
            {
                duration    = duration,
                startFloat  = startFloat,
                targetFloat = targetFloat
            };

            info.AddOnChangedCallback(SetHeight);
            info.ignoreTimeScale = true;
            this.m_FloatTweenRunner.StartTween(info);
        }
        /// <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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        /// <summary>
        /// Tweens the delete button 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>
        public void TweenDeleteButtonAlpha(float targetAlpha, float duration, bool ignoreTimeScale)
        {
            if (this.GetDeleteButtonCavnasGroup() == null)
            {
                return;
            }

            float currentAlpha = this.GetDeleteButtonCavnasGroup().alpha;

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

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

            floatTween.AddOnChangedCallback(SetDeleteButtonAlpha);
            floatTween.ignoreTimeScale = ignoreTimeScale;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
Esempio n. 17
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);
        }
Esempio n. 18
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);
        }
        /// <summary>
        /// Raises the bar fill change event.
        /// </summary>
        /// <param name="amount">Amount.</param>
        public void OnBarFillChange(float amount)
        {
            // Calculate the bar fill based on it's width and value
            float fillWidth = ((float)this.bar.imageComponent.rectTransform.rect.width * this.bar.imageComponent.fillAmount);

            // Check if the fill width is too small to bother with the ending
            if (fillWidth <= (1f + (float)this.offset))
            {
                this.targetImage.gameObject.SetActive(false);
                return;
            }
            else if (!this.targetImage.gameObject.activeSelf)
            {
                // Re-enable
                this.targetImage.gameObject.SetActive(true);
            }

            // Position the ending at the end of the fill
            this.targetImage.rectTransform.anchoredPosition = new Vector2(
                (this.offset + fillWidth),
                this.targetImage.rectTransform.anchoredPosition.y
                );

            // Check if the fill width is too great to handle the ending width
            if (fillWidth < this.defaultFinishWidth)
            {
                // Change the width to the fill width
                this.targetImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Round(fillWidth));
            }
            else if (this.targetImage.rectTransform.rect.width != this.defaultFinishWidth)
            {
                // Restore default width
                this.targetImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, this.defaultFinishWidth);
            }

            // Show / Hide the finish
            if (this.autoVisibility)
            {
                // Check if the finish needs the be shown
                if (this.bar.imageComponent.fillAmount >= this.showAfterPct && this.bar.imageComponent.fillAmount < this.hideAfterPct)
                {
                    // Fade in if not 100%
                    if (this.fading)
                    {
                        FloatTween floatTween = new FloatTween {
                            duration = this.fadeDuration, startFloat = this.canvasGroup.alpha, targetFloat = this.defaultFinishAlpha
                        };
                        floatTween.AddOnChangedCallback(SetFinishAlpha);
                        floatTween.ignoreTimeScale = true;
                        this.m_FloatTweenRunner.StartTween(floatTween);
                    }
                    else
                    {
                        this.SetFinishAlpha(this.defaultFinishAlpha);
                    }
                }
                else if (this.bar.imageComponent.fillAmount >= this.hideAfterPct || this.bar.imageComponent.fillAmount < this.showAfterPct)
                {
                    // Fade out at 100%
                    if (this.fading)
                    {
                        FloatTween floatTween = new FloatTween {
                            duration = this.fadeDuration, startFloat = this.canvasGroup.alpha, targetFloat = 0f
                        };
                        floatTween.AddOnChangedCallback(SetFinishAlpha);
                        floatTween.ignoreTimeScale = true;
                        this.m_FloatTweenRunner.StartTween(floatTween);
                    }
                    else
                    {
                        this.SetFinishAlpha(0f);
                    }
                }
            }
        }