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);
            }
        }
        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);
            });
        }