コード例 #1
0
        protected override void OnExit(Action onAnimationFinish)
        {
            var  current      = GetBaseAnimationEntry();
            bool hasAnimation = false;

            if (fade)
            {
                current      = current.Then(GetOpacityAnimationProperty(1f, 0f), duration);
                hasAnimation = true;
            }

            if (movementDirection != UIViewMovementDirection.None || scalingDirection != UIViewScalingDirection.None)
            {
                var delta = size0.InverseScale(RealScreen.uiSize) * (UICameraHelper.Active.orthographicSize * 2f);
                delta.Scale(Dir2Vector[(int)movementDirection] * movementPercentage);
                var size = size0 * (1f + Dir2Scale[(int)scalingDirection] * scalingPercentage);
                var prop = new RectTransformAnimationProperty(rt, pos0, pos0 - delta, size0.CloneScale(scale0),
                                                              size.CloneScale(scale0));
                current = hasAnimation ? current.And(prop, duration) : current.Then(prop, duration);
                current.With(exitFunction);
                hasAnimation = true;
            }

            if (rotationDirection != UIViewRotationDirection.None)
            {
                float angle = 360f * rotationPercentage * (int)rotationDirection;
                var   prop  = new RotationAnimationProperty(rt, new Vector3(0f, 0f, angle));
                rt.rotation = Quaternion.identity;
                current     = hasAnimation ? current.And(prop, duration) : current.Then(prop, duration);
                current.With(exitFunction);
            }

            current.Then(new ActionAnimationProperty(() =>
            {
                onAnimationFinish?.Invoke();
                SetToTransitionTarget();
            }));
        }
コード例 #2
0
        protected override void OnEnter(Action onAnimationFinish)
        {
            AnimationEntry current      = GetBaseAnimationEntry();
            bool           hasAnimation = false;

            if (fade)
            {
                current      = current.Then(GetOpacityAnimationProperty(0, 1), duration);
                hasAnimation = true;
            }

            if (movementDirection != UIViewMovementDirection.None || scalingDirection != UIViewScalingDirection.None)
            {
                var delta = size0.InverseScale(RealScreen.uiSize) * (UICameraHelper.Active.orthographicSize * 2);
                delta.Scale(Dir2Vector[(int)movementDirection] * movementPercentage);
                var size = size0 * (1 + Dir2Scale[(int)scalingDirection] * scalingPercentage);
                var prop = new RectTransformAnimationProperty(rt, pos0 - delta, pos0, size.CloneScale(scale0),
                                                              size0.CloneScale(scale0));
                current = hasAnimation ? current.And(prop, duration) : current.Then(prop, duration);
                current.With(enterFunction);
                hasAnimation = true;
            }

            if (rotationDirection != UIViewRotationDirection.None)
            {
                var   prop  = new RotationAnimationProperty(rt, Vector3.zero);
                float angle = 360 * rotationPercentage * (int)rotationDirection;
                rt.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
                current     = hasAnimation ? current.And(prop, duration) : current.Then(prop, duration);
                current.With(enterFunction);
            }

            if (onAnimationFinish != null)
            {
                current.Then(new ActionAnimationProperty(onAnimationFinish));
            }
        }