Version: Unity 6.1 (6000.1)
Language : English
Video Player component reference
Set up your Render Texture to display video

Create a Video Player component

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.

Create a Video Player from the menu or hierarchy

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.

Add the component to an existing GameObject

You can also add a Video Player component to an existing GameObject. To do this, either drag a video file onto the GameObject, or:

  1. Click on the GameObject.
  2. In the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
    See in Glossary
    window, select Add Component.
  3. Select Video > Video Player.

As a result, your GameObject contains a Video Player component.

Drag a video clip into the scene

The quickest way to create a Video Player component is to drag your video clip into the scene:

  1. Locate the video file in your Asset folder in Unity.
  2. Click and drag your file into an empty spot in the Scene Hierarchy, in the Scene viewAn interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info
    See in Glossary
    , or in the Inspector.

As a result, Unity creates a GameObject that contains a Video Player component and automatically assigns your video clip to the component.

Use C# scripting to add the component at runtime

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.

Additional resources

Video Player component reference
Set up your Render Texture to display video