Dynamicaly load a video on a GameObject

Hello,

I searched for a good while but all my attempts resulted in failures until now.
I need to write a script able to load and display on a GameObject a video from its very link. My point is to make sure by only writing down the disk link of the video on a text file, the referenced video will be loaded from a script.

My expectations went short when I couldn’t seem to manage to find proper “Resource.Load” like I did for loading textures from their link.

Anybody can land me a hand here ?

Thank you.

Edit: Idealy, I’d like to load a videoclip from its link.

Hello there,

If you have a (relatively) recent version of Unity, you might want to try their Video Player. It’s pretty simple, and seems to work great. I use it to have a video rendered on a plane.

In terms of code, you can play the video like this:

    public void PlayVideo(string videoName)
    {
        VideoClip clip = Resources.Load<VideoClip>(videoName) as VideoClip;
        vp_VideoPlayerRef.clip = clip;
        vp_VideoPlayerRef.Play();
    }

There are heavy restrictions on which formats it supports though, so I’d recommend reading the above link in details. But if you follow all their rules, you can just load a video from Resources and play it.

Hope that helps!

~LegendBacon