This tutorial explains the basics for creating a Unity scene to visualize a 360 video file.
It assumes that you have a 360 video file ready, and either you’ve created a new Unity project or are working on one where you want to have a 360 video in one of the scenes.
- Import your video file. You can do this by dragging & dropping it into the Project panel. Before doing so, note the size of the video in pixels (width and height; e.g. 2560×1280).
- Create a new Render Texture.
Right click on the project panel, where the assets are located, and select Create > Render Texture.
You can (and should) rename the Render Texture immediately after creating it, or at any time, using the project panel.
- Set the Render Texture’s size to the same as the video you want to play, so that it plays the video correctly.
Use the Render Texture’s Inspector panel to change the size parameters to fit those of the video pixels.
- Create a new material.
Right click on the project panel, where the assets are located, and select Create > Material.
- Link the Render Texture to the Material.
Click on the Material in the project panel, and view the corresponding Inspector panel, where, there is a field labelled Spherical (HDR).
In order to link the Render Texture to the Material, you can either click on the select button within the field, or simply drag the texture you created in step 2 into this field.
- Set the material as the scene’s Skybox
The final step with the material is to set it as the Skybox (the surrounding environment) in your scene.
You’ll need to do this using the Lighting panel, which you can open via the menu Window > Rendering > Lightning Settings.
In this panel, the first field is Skybox Material. Once more, you can set your material by dragging & dropping or by clicking on the select icon, which is the small circle on the right:
Once you’ve set your material, it should look something like this:
- The last step is to create a Video Player.
You can do this by using the menu GameObject > Video > Video Player, or by right clicking on the hierarchy panel and selecting Video > Video Player.
Now a Video Player object will appear on your Hierarchy panel. Make sure it is not a child of any 3D object there. i.e.: it is not indented and with a small arrow.
Click and drag to ‘unchild’ the camera if it looks like the first image.
- Reset the camera position to 0,0,0
Now that the focus is on the Hierarchy, make sure your camera is at the centre of the 3D world. This is not essential, but it makes sense, as you want your viewpoint in the centre.
Click on the Main Camera and, in the inspector’s top field, right click Transform (which marks any 3D object’s position, rotation and scale) and select reset.
Now the Transform should look like this:
- Set the Video Player to… play the video
Final step: Click on the video player and view the Inspector panel. We are interested in the fields Video Clip and Target Texture.
Once more, either by selecting the menu or by dragging & dropping, assign the video file you imported in step 1 to Video Clip and the Render Texture you created in step 2 to Target Texture.
- Click Play to test
Make sure your game window is visible somewhere on the Unity interface (Window > General > Game; or ctrl+2 (pc) / ⌘+2 (mac)), and click the Play button in the top central part of Unity:
If everything is correct, you should now visualize the video as seen by the main camera in the Game window (and most likely in a different perspective on your 360 video in the Scene window, which is where you manipulate the 3D elements).
Now you are ready to export your application and test it on a VR device or smartphone.
Recommended citation: SOLER-ADILLON, Joan. Unity: Basic 360 video. Mosaic [online article], November 2019, no. 176. ISSN: 1696-3296. DOI: https://doi.org/10.7238/m.n177.1960.
Deja un comentario