Every game has some sort of fade in/fade out transitions: between the levels, or when you enter a dialog or a cutscene, and so on. In Unity, we can create such transitions very easily using the Animation View.
You don't have to prepare anything for this recipe; everything is created in Unity from scratch. You can open the provided example Unity project and go to the Chapter 03 2D and user interface animation\Recipe 05 Creating a fade out - fade in transition with the animation view
directory. You will find an Example.unity
scene there. Play the game and press the space bar to see the fade in/fade out effect.
To create a fade in/fade out effect, follow these steps:
- Open a scene.
- Create an
Image
in theHierarchy
. To do so, go toGame Object
|UI
|Image
menu on the top of the screen. Image
andCanvas
game objects will be created in theHierarchy
.- Select the
Image
game object and set its name toBlackScreen...