There are two ways to start a WebVR enabled project using Unity.
-
This is the simplest option, to do this, download the project and open in Unity. You can follow steps from step #7 onwards to build the project to WebVR.
-
Start by Creating a new Unity 3D Project.
In this tutorial, we cover option 2, starting from new, stepping through each step from creating a new Unity project, adding the WebVR Assets, then building to WebVR.
Open an existing project, or click on the New
button and fill in the details of the new game:
Open the menus: File > Build Settings
See In-editor VR playback for rapid testing for full steps.
Alternatively, download and install the WebVR-Assets.unitypackage
from this repo and use (Assets > Import Package > Custom Package
) to import the package into your project.
Disable the standard default camera, so that it does not interfere with the cameras used in the WebVR prefab.
To do this, select Main Camera
from the scene's Hierarchy
; then, delete or disable the camera from the Inspector
.
Add the WebVRCameraSet
prefab (Assets > WebVR > Prefabs > WebVRCameraSet.prefab
):
The prefab contains hand controllers, VR Camera setup and other components needed for your game to work with WebVR.
Copy InputManager.asset
into your Project /ProjectSettings
folder. This will add pre-configured Unity Input Manager input axes needed for controllers to work.
See Controllers and Input System for more details about how this works.
Go to Edit > Project Settings > Player
:
Click on File > Build & Run
, select a destination folder and Unity will compile your code and and launch the game in your default browser. If you want to open the game in another browser, copy and paste the URL of the game.
Under the hood, when clicking Build & Run
, Unity will place all the needed files in the selected folder and will spin up a development web server pointing there. If you want to provide your own server, choose File > Build
instead.