public override void AnimateTransitionForInitialCanvasController(
            CanvasControllerTransitionContext transitionContext)
        {
            /*
             *  We implement different behaviour for transitions involving the
             *  initial canvas controller.
             */

            // Create an image overlay.
            ImageOverlay imageOverlay = new ImageOverlay();

            if (transitionContext.isUpstream)
            {
                /*
                 *  When dismissing an initial canvas controller we modify the
                 *  post-fade to fade to nothing.
                 */

                // Set the image overlay to transparent color.
                Color targetColorTransparent = color;
                targetColorTransparent.a = 0f;
                imageOverlay.Color       = targetColorTransparent;

                // Add the overlay to the source content.
                var source = transitionContext.sourceCanvasController;
                imageOverlay.SetParent(source.content);

                // Perform pre fade.
                PerformPreFade(imageOverlay, () =>
                {
                    // Pre-fade is complete. Set the source content to inactive and
                    // move the overlay to its parent (the canvas).
                    imageOverlay.SetParent(source.CanvasRectTransform());
                    source.ContentActive = false;

                    // Perform post-fade and complete transition on completion.
                    PerformPostFade(imageOverlay, transitionContext.CompleteTransition);
                });
            }
            else
            {
                /*
                 *  When presenting an initial canvas controller we skip the 'pre-fade'
                 *  and begin immediately at the transition color.
                 */

                // Set image overlay to the transition color immediately.
                imageOverlay.Color = color;

                // Add the overlay to the destination content.
                var destination = transitionContext.destinationCanvasController;
                imageOverlay.SetParent(destination.content);

                // Perform post-fade and complete transition on completion.
                PerformPostFade(imageOverlay, transitionContext.CompleteTransition);
            }
        }
Example #2
0
        public override void AnimateTransition(CanvasControllerTransitionContext transitionContext)
        {
            // Create our animation action.
            var animateContent = MoveContentAnimation(transitionContext);

            // Start a routine to animate our content.
            Routine animation = new Routine(duration, 0f, UpdateMode);

            animation.Run((progress01) =>
            {
                // Evaluate the animation curve with the current progress.
                float easedProgress01 = curve.Evaluate(progress01);

                // Execute our move animation action with the eased progress.
                animateContent(easedProgress01);
            }, transitionContext.CompleteTransition); // Call CompleteTransition() on completion.
        }
Example #3
0
    public ICanvasControllerTransitioningAnimator TransitioningAnimatorForContext(
        CanvasControllerTransitionContext transitionContext)
    {
        // The transitioning canvas controller will ask its transitioning animator
        // vendor (us) for an animator before transitioning. We can give it the
        // correct one depending on what canvas controller is transitioning.

        // The presented canvas controller is the destination on downstream transitions (Present)
        // and the source on upstream transitions (Dismiss).
        CanvasController presentedCanvasController = (transitionContext.isUpstream) ?
                                                     transitionContext.sourceCanvasController : transitionContext.destinationCanvasController;

        int animatorIndex = 0;

        if (presentedCanvasController is TEDefaultTransitionCanvasController)
        {
            animatorIndex = 0;
        }
        else if (presentedCanvasController is TEFadeTransitionCanvasController)
        {
            animatorIndex = 1;
        }
        else if (presentedCanvasController is TESlideTransitionCanvasController)
        {
            animatorIndex = 2;
        }
        else if (presentedCanvasController is TEScaleTransitionCanvasController)
        {
            animatorIndex = 3;
        }
        else if (presentedCanvasController is TEScaleAndFadeTransitionCanvasController)
        {
            animatorIndex = 4;
        }

        var animator = animators[animatorIndex];

        return(animator);
    }
        public override void AnimateTransition(CanvasControllerTransitionContext transitionContext)
        {
            // Set the destination content inactive.
            var destination = transitionContext.destinationCanvasController;

            destination.ContentActive = false;

            // Create an image overlay.
            ImageOverlay imageOverlay = new ImageOverlay();

            // Set the image overlay to transparent color.
            Color targetColorTransparent = color;

            targetColorTransparent.a = 0f;
            imageOverlay.Color       = targetColorTransparent;

            // Add the overlay to the source content.
            var source = transitionContext.sourceCanvasController;

            imageOverlay.SetParent(source.content);

            // Perform pre-fade.
            PerformPreFade(imageOverlay, () =>
            {
                // Pre-fade is complete. Move the image overlay to the destination canvas.
                var destinationContent = destination.content;
                imageOverlay.SetParent(destinationContent);

                // Make the source inactive and the destination active.
                source.ContentActive      = false;
                destination.ContentActive = true;

                // Perform post-fade and complete transition on completion.
                PerformPostFade(imageOverlay, transitionContext.CompleteTransition);
            });
        }