I’m using the Unity Video Player to play a video on a canvas. I believe I set up everything correctly, but the video visuals don’t appear on the Raw Image I’m using to render, but the audio plays just fine.
Here’s my setup:
-
Made a Render Texture. Set the dimensions.
-
Create a “Raw Image” object under my canvas. Add the render texture into the texture slot:
-
Make a empty game object with a Video Player component. Add the render texture to its texture slot:
-
I have a simple script that has a list of videos in an array. I assigned a video clip to the VideoPlayer, and the instructed it to play:
public class VideoController : MonoBehaviour
{
[SerializeField] private VideoPlayer mainVideo;
[SerializeField] private VideoClip[] videos;
private double[] vidLengths;
public double[] Video_Lengths
{
get { return vidLengths; }
}
private void Start()
{
vidLengths = new double[] { videos[0].length, videos[1].length, videos[2].length, videos[3].length };
}
public void PlayMain()
{
mainVideo.clip = videos[0];
mainVideo.Play();
}
public void StopMain()
{
mainVideo.Stop();
}
}
The video plays, but I only get the audio. I see the Render Texture and the VideoImage, but nothing appears on the actual screen.
Am I doing something wrong?
Thanks in advance.