How to do it...

To create a fade in/fade out effect, follow these steps:

  1. Open a scene.
  2. Create an Image in the Hierarchy. To do so, go to Game ObjectUIImage menu on the top of the screen.
  3. Image and Canvas game objects will be created in the Hierarchy.
  4. Select the Image game object and set its name to BlackScreen.
  5. Right-click on the Canvas game object and choose Create Empty to create an empty game object.
  6. Set the name of the newly created game object to FadeAnimator. This object will animate the effect.
  7. Set the Anchor Preset of the BlackScreen and FadeAnimator game objects to stretch in both X and Y coordinates, as shown in the following screenshot:
  1. Set the LeftTopRight, and Bottom position parameters to 0 in both the BlackScreen ...

Get Unity 5.x Animation Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.