Example #1
0
        public void MoveAnchors(Vector2 anchorMin, Vector2 anchorMax,
                                UIAnimationDirection animationDirection = UIAnimationDirection.From, Action callback = null,
                                UIAnimationOptions animationOptions     = null)
        {
            var anchors = new Vector4(anchorMin.x, anchorMin.y, anchorMax.x, anchorMax.y);

            AnchorsTweener.Tween(anchors, animationDirection, callback, animationOptions);
        }
Example #2
0
        public void Tween(TProperty value, UIAnimationDirection animationDirection = UIAnimationDirection.From,
                          Action callback = null, UIAnimationOptions animationOptions = null)
        {
            if (animationOptions == null)
            {
                animationOptions = new UIAnimationOptions();
            }

            if (tweenerCoroutine != null && tweenerCoroutine.Running)
            {
                StopTween();
                tweenerCoroutine.OnFinished += b => {
                    Tween(value, animationDirection, callback, animationOptions);
                };
                return;
            }

            if (animationDirection == UIAnimationDirection.RelativeTo || animationDirection == UIAnimationDirection.RelativeFrom)
            {
                value = AddValues(value, TargetValue);
            }

            if (animationDirection == UIAnimationDirection.To || animationDirection == UIAnimationDirection.RelativeTo)
            {
                TargetValue = value;
            }
            else
            {
                TargetValue  = CurrentValue;
                CurrentValue = value;
            }

            if (animationOptions.SavePosition)
            {
                SavedValue = TargetValue;
            }

            if (animationOptions.Instant)
            {
                CurrentValue = TargetValue;
                return;
            }

            Tweening = true;

            tweenerCoroutine             = _owner.CreateCoroutine(TweenCoroutine(animationOptions.Ease, animationOptions.Duration, animationOptions.Delay));
            tweenerCoroutine.OnFinished += stopped => {
                if (!stopped)
                {
                    CurrentValue = TargetValue;
                }

                Tweening = false;

                callback?.Invoke();
            };
        }
Example #3
0
 public void Fade(float fade, UIAnimationDirection animationDirection = UIAnimationDirection.To,
                  Action callback = null, UIAnimationOptions animationOptions = null)
 {
     AlphaTweener.Tween(fade, animationDirection, callback, animationOptions);
 }
Example #4
0
 public void Scale(Vector3 scale, UIAnimationDirection animationDirection = UIAnimationDirection.From,
                   Action callback = null, UIAnimationOptions animationOptions = null)
 {
     ScaleTweener.Tween(scale, animationDirection, callback, animationOptions);
 }
Example #5
0
 public void Resize(Vector2 size, UIAnimationDirection animationDirection = UIAnimationDirection.RelativeTo,
                    Action callback = null, UIAnimationOptions animationOptions = null)
 {
     SizeTweener.Tween(size, animationDirection, callback, animationOptions);
 }
Example #6
0
 public void Rotate(Vector3 rotation, UIAnimationDirection animationDirection = UIAnimationDirection.From,
                    Action callback = null, UIAnimationOptions animationOptions = null)
 {
     RotationTweener.Tween(rotation, animationDirection, callback, animationOptions);
 }
Example #7
0
 public void Move(Vector3 position, UIAnimationDirection animationDirection = UIAnimationDirection.To,
                  Action callback = null, UIAnimationOptions animationOptions = null)
 {
     PositionTweener.Tween(position, animationDirection, callback, animationOptions);
 }