Who said teleworking had to be boring?! Ever wanted to chat with your friends or see what’s happening on the other side of the world while in VR? What about a VR trade show where you can stream straight from businesses to your VR app? Interested in getting up and running with Oculus Quest but not sure where to get started? This quick guide teaches you how to integrate Oculus Quest and create a drag-and-drop solution for Agora real-time live video streaming, which is backed by their amazing subsecond latency global network.
All you need:
To start, open Unity and create a blank new project named Agora Quest Demo.
Switch Build Platform
Because we’re building for Oculus Quest, we can go ahead and change the platform to Android by going to File > Build Settings and choosing Android in the Platform section.
Be sure you set your Texture Compression to ASTC.
Next, navigate to the Unity Asset Store (in the scene view, click the Asset Store tab) and import and download two assets: Oculus Integration and Agora Video Chat SDK. Oculus takes care of a lot of the heavy lifting of getting started in VR, and Agora has your back when it comes to global communication.
While downloading the Oculus Integration package, you will be prompted to update your Spatializer plug-in and restart your Unity Editor. Click Ok and Restart when they pop up.
Modify Project Settings
First, we need to change a few parameters in the player settings, so go to File > Build Settings > Player Settings. At the top of the Inspector, update Company Name and Product Name.
Next, go to Other Settings and deselect Auto Graphics API and get rid of Vulkan.
Now change Package Name to match Company and Project (which you set earlier) and change Minimum API Level to API level 21.
Last, scroll down to the bottom to XR Settings. Select Virtual Reality Supported, and under Virtual Reality SDKs select Oculus.
Make a Scene
This time we won’t be making a scene as much as we will use a premade scene from Oculus found at Assets > Oculus > VR > Scenes > Room and modify it to fit our needs. Open the room scene, which is an empty room with light decoration and some simple hand geometry. In other words, the perfect canvas to start with because we are focusing on getting communication running. I will remove a couple of walls in a feeble attempt to make the scene my own and then create an Empty GameObject to set as a location placeholder for my video screens. I name this object VideoSpawn and move the position right in front of the camera at a Z position of 1.92.
Create A New Material
We will display the incoming video stream on a plane object. On the plane, we will define our own material. In the Resources folder, create a new Material and name it “PlaneMaterial”. Select “Mobile/Unlit” as its Shader.
Note: If you skip this step, you will see a pink Texture show on your Plane object when a remote user video stream starts.
Create an Agora Drag And Drop Prefab Instance
We need a way for our app to talk to the Agora network. The fastest way to do that is to create an Agora prefab by creating an Empty GameObject in the scene and naming it AgoraInstance. Then take the code snippet below and add it to the new AgoraInstance.
You can now drag this into your hierarchy to save it as a prefab. Anytime you drop this into a scene it will allow you to automatically create an Agora instance and join a scene when the prefab is activated.
In the Inspector, you can add your Agora App ID and whatever room name you want to test in.
Modify Android Manifest
You need to modify your Android manifest file. Because the Oculus Quest doesn’t have cameras (well, none that can be use for this demo), we will get rid of the camera use requirement (android:name=”android.permission.CAMERA”/>) on line 9 in the folder Assets > Plugins > Android > AgoraRtcEngineKit.plugin.
Test on Device
Now you need something to test on. You have tons of options because Agora is not Unity specific. You could just create a sample Agora video scene. If you are on a Mac, you can learn how to do that here. If you are on a Windows computer, you can learn how to do that here. But for the convenience, you may just use our Web demo to run the test as remote user.
Now that you have some live video coming down the pipe, return to the Unity Editor and select File > Build Settings. Drag and drop your modified room scene into the Scenes to Build section. Note that the new Oculus has its build script, so you don’t just click Build And Run on the Unity Editor Build window. Instead, you go the Oculus menu and select Build And Run. A screenshot is below.
After a short loading sequence, your app will deploy to your Oculus Quest headset. Congratulations! If you want to run your app from within the Oculus Quest headset without rebuilding, inside your headset go to Library > UnkownSources to see your app. Great job!
- The Agora Video SDK for Unity available on the Unity Asset Store.
- Get the Source Code for the web app here.
- The complete API documentation is available in the Document Center.
- For technical support, submit a ticket using the Agora Dashboard.
- The complete Oculus Documentation is available here.