Skip to main content

Ready to market your stellar app?

Samsung Developer Program is your gateway to app monetization success.

Learn More

Samsung Developer Program

Step 2: Create the ScreenFader Object

 

This is the essential step to use screen fader effects in your Gear VR app or game.

For other steps in this exercise, see Exercise 5: Add a Screen Fader Effect.

 

To create a ScreenFader object: 

  1. Return to the Splash.unity file.

 

  1. From the Hierarchy view, select Create > Create Empty.

 

  1. From the Inspector view, change the name of the empty object to ScreenFader and press Enter to register the change.

 

  1. From the Transform component, click the Gear icon and select Reset to make sure the object is positioned at (0, 0, 0).

 

  1. From the Project view, open the /Assets/Workshop/Meshes folder and drag the Sphere_Inv object onto the ScreenFader object in the Hierarchy view. The ScreenFader object will be used to fade the Splash screen to black as it transitions to the Main scene. It will also be used to create a fade transition between images in the viewer.

 

  1. With the ScreenFader > Sphere_Inv object still selected, go to the Inspector view and change the Scale property's X, Y, and Z values to 0.01. This will reduce the size of the sphere so that it only covers the camera.

 

  1. Review the scene in the Game view. Since the sphere is not transparent, you should only see a gray screen.

 

  1. From the Project view, open the /Assets/Workshop/Materials folder and drag the ScreenFader material into the Mesh Renderer > Materials > Element 0 field in the Inspector view.

 

  1. Preview the scene in Game view. You will be able to see the scene once again. The ScreenFader material only contains a color (black) with an alpha value set to 0.

 

  1. From the Inspector view, click the Add Component button and select Scripts > Screen Fader Sphere. This script controls the duration of the fade effect. By default, it is set to 0.3 seconds for the fade-to-black and fade-to-transparent effects.

 

  1. Click the Add Component button and select Scripts > Anim Shader Alpha. This script tells the Screen Fader Sphere when to start modifying the alpha value over a specified amount of time. In this case, the scene will start the fade-to-black effect one second before transitioning to the Main scene.

NOTE: The duration of the Screen Fader Sphere script's Fade-to-Black property should not exceed the duration of Anim Shader Alpha script, or the scene will switch before completely fading to black.

 

  1. Review the timeline of events. At 0 seconds, the Splash scene starts. The StartApp object sets the duration of the Splash scene to 5 seconds. At the 4 second mark, the Anim Shader Alpha and Screen Fader Black scripts are triggered and the scene begins to fade to black. At 4.3 seconds, the Screen Fader Sphere completes. At the 5 second mark, the Main scene starts.

 

  1. Play the scene. You will see the Splash scene fade to black and transition to the Main scene. Notice that the Main scene does not fade from transparent to black when it starts. You will need to implement the ScreenFader object in the Main scene in order for this transition to display.

 

  1. Save the scene.

 

 

  • Was this article helpful?