Using scripting to control video playback on scene textures
While the last recipe demonstrated how we can plan videos using the Video Player component that's set up at design time, much more is possible when controlling video playback through scripting.
In this recipe, we'll using scripting to play/pause the playback of a video rendered onto a 3D cube:

Getting ready
If you need a video file to follow this recipe, please use the videoTexture.mov
file included in the 13_01
folder.
How to do it...
To use scripting to control video playback, follow these steps:
- Import the provided
videoTexture.mov
file. - Create a 3D cube by choosing menu:
Create
|3D
|Cube
.
- Create a C# script class named
PlayPauseMainTexture
, and attach an instance object as a component to your 3D cube GameObject:
using UnityEngine; using UnityEngine.Video; [RequireComponent(typeof(VideoPlayer))] [RequireComponent(typeof(AudioSource))] public class PlayPauseMainTexture : MonoBehaviour { public VideoClip...