Create a Video Player component to play videos in your sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary.
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 GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary 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# scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary. 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.