Create a Video Player component to play videos in your scene.
There are a few ways to create a Video Player component in Unity. Choose from one of the following methods:
After you set up your component, you can configure the settings to your liking. For information about the settings, refer to Video Player component reference.
To create the Video Player component from the menu, select GameObject > Video > Video Player.
Alternatively, in the Hierarchy, select the Add (+) button and then select Video > Video Player.
Either method creates a new GameObject with a Video Player component attached.
You can also add a Video Player component to an existing GameObject. To do this, either drag a video file onto the GameObject, or:
As a result, your GameObject contains a Video Player component.
The quickest way to create a Video Player component is to drag your video clip into the scene:
Asset folder in Unity.As a result, Unity creates a GameObject that contains a Video Player component and automatically assigns your video clip to the component.
You can also use scripting to add a VideoPlayer component to a GameObject and configure its settings using C# scripts. Here’s an example code snippet:
// Add a Video Player component to the GameObject.
VideoPlayer videoPlayer = gameObject.AddComponent<VideoPlayer>();
This code dynamically adds a Video Player component to the GameObject that contains this script at runtime.
You can then use the videoPlayer variable to access and modify the Video Player’s properties.