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.  The contents in this guide was written with the GearVR and Google Daydream in mind, but should be applicable to any setup.

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/

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?

  • Toby Christopher Tangalin

    Also experiencing the same problem as Shashkes Sarit.
    I’ve noticed that when I download and add the invertedsphere, there is no Sphere.inverted.16 nor Animator component.
    Running 5.61f1 on Windows 10. Please send help.

    Regards,

    Toby

    https://uploads.disquscdn.com/images/4bd9e4b68540d226de3b00d4f45fb7976c7ab18f4987cf3b7919ccd9b5b4a938.png

  • JW

    There appears to be something wrong with the inverted sphere mesh, will get that fixed up asap.

    However, the method shown for creating an inverted sphere here will work – https://unity3d.college/2017/05/15/building-an-interactive-mobile-360-video-player-gearvr/

  • wajisan

    does this work for someone ?

    • JW

      Did it not work for you?

      There was a change since the recent comments to replace the .fbx with the steps from another post to generate a sphere.

      I just opened the project and it seems to still run fine.

      If it happens to fail for you, can you post the console log so we can debug what’s going on?

    • wajisan

      okay, i finally makes this work, the problem were in the inverted sphere. i don’t know why but i finally created it in blender ( with the first part of this tutorial https://www.youtube.com/watch?v=3IQDwl7IAXI ), after this, everything work

      Thanks 🙂