In this tutorial you will learn playing a video in unity.
A good way to learn about this object is going to official documentation for the video player
The first thing to do is to create an empty Game object and attach a video player :
You will need multiple things, the most important one is a video, if you do not have any you can download the AMV I am using :
Homuras-Seven-Devils-AMVAfter the video clip is downloaded you need to import it in Unity, by simply dragging and dropping the file into the asset folder.
You can then chose a Render mode you have a lot of choices :
By selecting this mode you will need to specify a Camera and the video will render in this Camera, you only have the main camera in the project so pick this one and the video will be rendered full screen.
Here is the result of using the camera mode :
You can chose to render the output of the video on a render texture. A render texture is a special texture that can be render in real time. You need to create one first in the assets :
After the render texture is created you will need to specify a size, the AMV I am using is in 720p that means a resolution of 1280ร720 so I specify the sizes :
After the texture is done we need to use it ๐
In a 3d game the simplest flat object with a material is a cube, so letโs create a cube to apply the render texture on it !
Yes, but what the size of the cube ? Same as before we want to have the same ratio 1280ร720 => 12.80ร7.20
Aftet the cube is created with the right size you can drag and drop the render texture on it.
When you hit play does the video is inverted ? Yes ? Try to position the camera to the opposite side, the video will look normal.
Yes it can seem weird at first but the render texture is applied on every face of the cube like any other material.
The position for my Camera is :
The orientation of the light is also important :
You also need to disable the reflection of the light on the render texture, for that click on the cube inside the property of the render texture material disable :
After all that the project should be looking good to go with a render texture ๐