In virtual reality project, voice communication is almost a necessary function. While searching the web for various Unity SDKS, I found one that was perfect for beginners with good sound quality, low latency, strong resistance to dropped calls, and 10,000 free minutes per month. Here’s how to quickly integrate agora’s voice SDK in just a few steps.

Oculus installation 2 Acoustic SDK installation 3 Photon Installation 4 Comprehensive application

The first chapter

  1. Oculus installation

    A) New Unity project

    B) Switch to android platform and open Player Setting



    D) Add XR plugin (after 4, 2019.4), open PC and mobile Oculus option, if you have Quest Link installed on PC debugging will be more convenient





    E) Modify other Setting in Player to meet oculus requirements





    F) Import the Oculus SDK from the store



    G) complete

    The second chapter

  2. Sound network installation

  3. To build unity first, I used the 2019.4 version.

    4

  4. And then you go to the Asset Store

  5. Search Agora, click Agora Voice

  6. Click Download, then Import

  7. Import all the resources into Unity

  8. Open HelloUnity3D project

  9. Enter your APP ID in GameController.

  10. Click “Run”, you can see the project UI below, the text box is to enter the room number, the button is to enter the room

  11. For a simple test, enter lobby, click Run, and click Join

  12. IO /agora-web-s webdemo.agora. IO /agora-web-s…

  13. To register an account, go to www.agora.io/cn/ and click Register

  14. Fast registration can be used, do not want to fill so much can use the left wechat registration

  15. Click the crystal ball on the left to create your own project (name you like), then click the small eye on the right to see and copy your APP ID, copy it in Unity, registration efficiency is very high

The third chapter

Photon installation

A) Download photon SDK from official stores



B) After importing, you need to fill in Photon’s AppID. For details, see Registering Connections



C) Photon is now installed

The fourth chapter

The integrated use of

A) thinking

I. The main scene uses the Oculus Debug UI

Ii. Import the menu of soundnet into the main scene as prefab and use it as the login interface

Iii. The hands and head (a square) will be made into a Prefab that is automatically generated when the player loads and connected to the player’s own tracking system

B) Start opening the HelLounity3D scene and pull down the Canvas and GameController to make prefab (will be used in coulus scene later)



C) Open the debug UI scene, pull up the previous Canvas and GameController, set the size, position, and mode to World spCAE.





D) Start creating the head and hands of the character. Create a new cube as the head and pull the right hand and left hand of the CustomHand

Go under the cube





E) Set the cube’s properties (about 0.3m in size) and add a Photon View script to it. Add photon View to both hands so that they can see it on the network



F) Write a script that will be generated and automatically attached to the head and hands tracking system, so that others can see you as you move. The script will be attached to Cube and left and right hands, and objName will be filled in

using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; public class AttachToCamera : MonoBehaviourPun { public GameObject cam; public string objname; // Start is called before the first frame update void Start() { if (photonView.IsMine) { cam = GameObject.Find(objname);  this.transform.SetPositionAndRotation(cam.transform.position, cam.transform.rotation); this.transform.parent = cam.transform; } } // Update is called once per frame void Update() { } }Copy the code

G) Objname fills CenterEyeAnchor, LeftHandAnchor, RightHandAnchor

H) Pull the Cube into the Resources folder to program the Prefab and delete the scene cube



I) Start the Photon generation process by creating an empty PhotonManager object and hanging it with two scripts as shown in the image above. One will automatically enter the room and the other will automatically generate characters after joining.



J) we need to add the OvrRayCaster script to the gamepad detection menu



K) Virtual reality keyboard input is not convenient. First set a preset room number 123 for Agora, and then write keyboard input later



M) Click the Play button, and photon will automatically enter the room. Click the “A” button on the controller to enter JoinChannel

N) Click the upper left menu, File -> Build Setting



O) Install the exported APK into Oculus Quest, run it, and finish