Playing videos by manually adding a VideoPlayer component to a GameObject
TV sets, projectors, monitors.... If you want complex animated materials in your level, you can play video files as texture maps. In this recipe, we will learn how to add and use VideoPlayer components on the main camera.
Getting ready
If you need a video file so that you can follow this recipe, please use the videoTexture.mov
file included in the 13_01
folder.
How to do it...
To place videos manually with a VideoPlayer component, follow these steps:
- Import the provided
videoTexture.mov
file. - Add a 3D Cube to the scene by choosing menu:
GameObject
|3D Object
|Cube
.
- Select the Main Camera GameObject, and in the Inspector, add a Video Player component by clicking
Add Component
, and choosingVideo
|Video Player
. Unity will have noticed that we are adding the Video Player component to a camera, and so should have set up the default properties correctly for us:Play On Awake
(Checked)Wait For First Frame
(Checked)Render Mode...