Unity 5.6 introduced a bunch of great new features including a new video player. If you tried playing video in Unity 5.5, you know it’s a bit of a pain and generally requires an expensive plugin. I tried doing some Unity 360 Video projects in the past and ran into nothing but pain. I’m happy to say though that the latest version makes it much easier to render 360 video in Unity. The contents in this guide was written with the and in mind, but should be applicable to any setup.
Note on 3D 360
This post covers 360 video but not stereo 3D video.
If you’re looking to play 3D 360 Video check out this post: https://unity3d.college/2017/07/31/how-to-play-stereoscopic-3d-360-video-in-vr-with-unity3d/
How to get started
Before you can render 360 video, you’ll need a surface to render it on. Typically, we use a sphere with inverted normals (the sphere renders on the inside only).
You can create your own, search online, or download this one here: https://unity3dcollegedownloads.blob.core.windows.net/vrgames/invertedsphere.fbx
To create an inverted sphere, follow the steps outlined here – https://unity3d.college/2017/05/15/building-an-interactive-mobile-360-video-player-gearvr/
Create a new scene
Drag your inverted sphere to the Hierarchy.
Reset it’s position to (0, 0, 0), if it’s not already.
Set the sphere’s scale to (-3000, 3000, 3000).
If you’re using a different sphere than the one provided above, you may need a different scale value.
Without the scale’s X value is set negative here, the video would appear backward
Reset your camera’s position to (0, 0, 0)
Select a 360 video to play.
You can shoot your own or download one..
I used this video to test – https://www.youtube.com/watch?v=a5goYOaPzAo, but most 360 videos should work.
If you aren’t sure how to download videos from youtube, this is the site I use to do it: http://keepvid.com/
Drag the video onto the sphere in the scene view.
Select the Inverted Sphere
You should see the Video Player component added to the sphere.
You’ll also see the Video Clip assigned with your 360 video.
Because Play on Awake is selected, you can just hit play now and watch your video start playing.
Ready to add some basic controls to the player?
Let’s add keyboard controls to pause and play the video.
Create a script named VideoPlayerInput.cs
Replace the contents with this:
Add the VideoPlayerInput component to the Sphere.
Use the “Space” key to pause and resume playing of your video.
With Unity 5.6, playing video has become simple. You can play 2D video, 360 video, and even render video on any material you want (we used an inverted sphere, but you could attach it to a fire truck or whatever other model you pick really).
Try out all the new functionality, if you build something interesting, share it below!