360 Video in Unity 5.6

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.

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

Setup

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.

Play Controls

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.

 

Press Play

Use the “Space” key to pause and resume playing of your video.

Conclusions

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!

  • Shashkes Sarit

    this isn’t working for me. when i play the scene i’m still seeing things from outside the sphere. there seem to be some color changes but no video. any advice what i’m doing wrong?