コード例 #1
1
 private void DoTween(float target)
 {
     var floatTween = new FloatTween { duration = _blinkFrequency, startFloat = _canvasGroup.alpha, targetFloat = target };
     floatTween.AddOnChangedCallback(SetCanvasAlpha);
     floatTween.AddOnFinishCallback(() => { _blinkLock = false; });
     floatTween.ignoreTimeScale = true;
     floatTween.easing = TweenEasing.Linear;
     this._floatTweenRunner.StartTween(floatTween);
 }
コード例 #2
0
ファイル: Test_Fill.cs プロジェクト: DevDanSTL/ggj2016
        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);
        }
コード例 #3
0
ファイル: Test_LoadingBar.cs プロジェクト: DevDanSTL/ggj2016
        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);
        }
コード例 #4
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);
		}
コード例 #5
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, 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);
        }
コード例 #6
0
    void StartTween(float targetFloat, float duration)
    {
        if (_bar == null)
        {
            return;
        }

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

        floatTween.AddOnChangedCallback(SetFillAmount);
        floatTween.AddOnFinishCallback(OnTweenFinished);
        floatTween.ignoreTimeScale = true;
        floatTween.easing          = _easing;
        m_FloatTweenRunner.StartTween(floatTween);
        _isTweening = true;
    }
コード例 #7
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);
        }
コード例 #8
0
        /// <summary>
        /// Tweens the transform rotation.
        /// </summary>
        /// <param name="targetRotation">Target rotation.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="ignoreTimeScale">If set to <c>true</c> ignore time scale.</param>
        private void StartTween(float targetRotation, float duration, bool ignoreTimeScale)
        {
            float currentRotation = this.transform.eulerAngles.y;

            if (currentRotation.Equals(targetRotation))
            {
                return;
            }

            var floatTween = new FloatTween {
                duration = duration, startFloat = currentRotation, targetFloat = targetRotation
            };

            floatTween.AddOnChangedCallback(SetRotation);
            floatTween.AddOnFinishCallback(OnTweenFinished);
            floatTween.ignoreTimeScale = ignoreTimeScale;
            floatTween.easing          = this.m_Easing;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
コード例 #9
0
        protected override void Start()
        {
            base.Start();

            if (Duration <= 0)
            {
                CanvasGroup.alpha = TargetValue;
                return;
            }

            var floatTween = new FloatTween {
                duration    = Duration,
                startFloat  = CanvasGroup.alpha,
                targetFloat = TargetValue
            };

            floatTween.AddOnChangedCallback(UpdateAlpha);
            floatTween.AddOnFinishCallback(Finished);
            Runner.StartTween(floatTween);
        }
コード例 #10
0
        /// <summary>
        /// Starts the color tween.
        /// </summary>
        /// <param name="targetAlpha">Target alpha.</param>
        /// <param name="instant">If set to <c>true</c> instant.</param>
        private void StartCanvasGroupTween(float targetAlpha, bool instant)
        {
            if (this.m_TargetCanvasGroup == null)
            {
                return;
            }

            if (instant || this.m_Duration == 0f || !Application.isPlaying)
            {
                this.SetCanvasGroupAlpha(targetAlpha);
            }
            else
            {
                var floatTween = new FloatTween {
                    duration = this.m_Duration, startFloat = this.m_TargetCanvasGroup.alpha, targetFloat = targetAlpha
                };
                floatTween.AddOnChangedCallback(SetCanvasGroupAlpha);
                floatTween.ignoreTimeScale = true;

                this.m_FloatTweenRunner.StartTween(floatTween);
            }
        }
コード例 #11
0
        private void StartIntensityTween(float target, float duration)
        {
            if (this.m_Light == null)
            {
                return;
            }

            if (!Application.isPlaying || duration == 0f)
            {
                this.m_Light.intensity = target;
            }
            else
            {
                var colorTween = new FloatTween {
                    duration = duration, startFloat = this.m_Light.intensity, targetFloat = target
                };
                colorTween.AddOnChangedCallback(SetIntensity);
                colorTween.ignoreTimeScale = true;

                this.m_TweenRunner.StartTween(colorTween);
            }
        }
コード例 #12
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);
        }
コード例 #13
0
		/// <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);
		}
コード例 #14
0
		/// <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);
				}
			}
		}
コード例 #15
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);
        }
コード例 #16
0
ファイル: Test_FadeInOut.cs プロジェクト: Daloupe/Syzygy_Git
        /// <summary>
        /// Tweens the canvas group 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 StartAlphaTween(float targetAlpha, float duration, bool ignoreTimeScale)
        {
            if (this.m_Group == null)
                return;

            float currentAlpha = this.m_Group.alpha;

            if (currentAlpha.Equals(targetAlpha))
                return;

            var floatTween = new FloatTween { duration = duration, startFloat = currentAlpha, targetFloat = targetAlpha };
            floatTween.AddOnChangedCallback(SetAlpha);
            floatTween.AddOnFinishCallback(OnTweenFinished);
            floatTween.ignoreTimeScale = ignoreTimeScale;
            floatTween.easing = this.m_Easing;
            this.m_FloatTweenRunner.StartTween(floatTween);
        }
コード例 #17
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.AddOnFinishCallback(OnTweenFinished);
     floatTween.ignoreTimeScale = true;
     floatTween.easing = this.m_TransitionEasing;
     this.m_FloatTweenRunner.StartTween(floatTween);
 }
コード例 #18
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);
		}
コード例 #19
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);
		}