示例#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);
        }
示例#2
0
        public void Animate(UIAnimator animator, Action callback = null, UIAnimationOptions animationOptions = null)
        {
            if (animationOptions == null)
            {
                animationOptions = new UIAnimationOptions(savePosition, Duration == 0, _customEasingFunction, Duration, Delay);
            }

            if (animatePosition)
            {
                animator.Move(positionDelta, positionAnimationDirection, callback, animationOptions);
                callback = null;
            }

            if (animateAnchors)
            {
                animator.MoveAnchors(minAnchorDelta, maxAnchorDelta, anchorsAnimationDirection, callback, animationOptions);
                callback = null;
            }

            if (animateRotation)
            {
                animator.Rotate(rotationDelta, rotationAnimationDirection, callback, animationOptions);
                callback = null;
            }

            if (animateSize)
            {
                animator.Resize(sizeDelta, sizeAnimationDirection, callback, animationOptions);
                callback = null;
            }

            if (animateScale)
            {
                animator.Scale(scaleDelta, scaleAnimationDirection, callback, animationOptions);
                callback = null;
            }

            if (animateAlpha)
            {
                animator.Fade(alphaDelta, alphaAnimationDirection, callback, animationOptions);
                callback = null;
            }

            callback?.Invoke();
        }
示例#3
0
 public void Fade(float fade, UIAnimationDirection animationDirection = UIAnimationDirection.To,
                  Action callback = null, UIAnimationOptions animationOptions = null)
 {
     AlphaTweener.Tween(fade, animationDirection, callback, animationOptions);
 }
示例#4
0
 public void Scale(Vector3 scale, UIAnimationDirection animationDirection = UIAnimationDirection.From,
                   Action callback = null, UIAnimationOptions animationOptions = null)
 {
     ScaleTweener.Tween(scale, animationDirection, callback, animationOptions);
 }
示例#5
0
 public void Resize(Vector2 size, UIAnimationDirection animationDirection = UIAnimationDirection.RelativeTo,
                    Action callback = null, UIAnimationOptions animationOptions = null)
 {
     SizeTweener.Tween(size, animationDirection, callback, animationOptions);
 }
示例#6
0
 public void Rotate(Vector3 rotation, UIAnimationDirection animationDirection = UIAnimationDirection.From,
                    Action callback = null, UIAnimationOptions animationOptions = null)
 {
     RotationTweener.Tween(rotation, animationDirection, callback, animationOptions);
 }
示例#7
0
 public void Move(Vector3 position, UIAnimationDirection animationDirection = UIAnimationDirection.To,
                  Action callback = null, UIAnimationOptions animationOptions = null)
 {
     PositionTweener.Tween(position, animationDirection, callback, animationOptions);
 }
示例#8
0
        // ReSharper disable once MethodOverloadWithOptionalParameter
        public void Play(UIAnimation uiAnimation, bool resetToSavedProperties = false, Action callback = null, UIAnimationOptions animationOptions = null)
        {
            if (uiAnimation == null)
            {
                callback?.Invoke();

                return;
            }

            // TODO concurrent animations; hover & click at the same time
            // track all animations; some animations stop other animations (e.g. close stops open)
            if (_currentAnimation != null)
            {
                if (uiAnimation == GetAnimation(UIAnimationType.OnOpen) ||
                    uiAnimation == GetAnimation(UIAnimationType.OnClose))
                {
                    _currentAnimation.Stop(this);
                }
                else
                {
                    return;
                }
            }

            if (resetToSavedProperties)
            {
                ResetToSavedProperties();
            }

            OnAnimationStart(uiAnimation);

            Action animationCallback;

            if (callback == null)
            {
                animationCallback = () => { OnAnimationEnd(uiAnimation); };
            }
            else
            {
                animationCallback = () => {
                    OnAnimationEnd(uiAnimation);
                    callback();
                };
            }

            uiAnimation.Animate(this, animationCallback, animationOptions);
        }