In the preceding recipe, the movie has time to prepare since the game waits until we press the jumo/space key. If we are using scripting to set up a Video Player for a video clip, we need to do some initial work before the video is ready to play. Unity provides the prepareCompleted event, which allows us to register a method to be invoked once a VideoPlayer is ready to play.
Do the following:
- Add a UI Raw Image to the scene by choosing menu: Create | UI | Raw Image.
- Create a new empty GameObject named video-object.
- Create a C# script class named PrepareCompleted, and attach an instance object as a component to GameObject's video-object:
using UnityEngine; ...