Something that makes all games more fun is having the ability to see and speak with other players in the game. Games have been including voice chat services for years but when it comes to video there are limited options especially when using Unity. The best option I’ve found is the Agora Video SDK for Unity available through the Unity Asset Store.
Getting a sample Android app up and running is simple and took less than 10 minutes. Let’s run through the steps together.
- Unity Editor
- A developer account with Agora
To start, open Unity and create a blank new project named Agora Video Demo.
The next step is to navigate to the Unity Store (if you are in the scene view, click the Unity Store tab) and search for “Agora voice SDK”. Once the plugin page has loaded, go ahead and click Download. Once the plugin page has loaded, go ahead and click Download. Once the download is complete, click and Import the assets into your project.
Great! Now that we have the plugin downloaded and imported to our project we need to make 1 quick update before we can build and run our app. Double click the
TestSceneScript.cs file within the assets panel to edit it.
The file will open in Visual Studio (Unity’s default code editor). Let’s scroll down to
private string appId = "YOUR APP ID";
At this point we need to log into our Agora developer account and create a new AppID or select an existing one. I had previously created one so I’ll copy paste this appid into the
“ ” on
line 19. Make sure to save your changes.
We can scroll through the
TestSceneScript.cs file to see all the various event callbacks the Agora Voice SDK for Unity offers.
Running the Sample Application
Open the Build Settings and drag the
TestSceneHomeWorld.unity scenes from the assets list into the “Scenes in Build” list. Select Android from the Platform list and click Switch Platform.
Once Unity finishes its setup process, open the Player Settings. We need to make some changes to the player settings. First deselect Multithreaded Rendering option and deselect the Auto Graphics API. Next, within the Graphics API options that are now visible, make sure only OpenGLES2 is on the list (you may need to add it using the `+` icon) and remove any other APIs that may appear on the list.
Lastly, be sure our Android app also has a unique package name, I chose
com.agora.voicedemo. Make sure your Android device is plugged and click Build And Run. Unity will prompt you to save your project, I named my build Android.
Note: Newer versions of Unity will ship with a new version of gradle and this can cause compile errors. You may run into an issue when building for Android, where Unity throws an error “Unable to build gradle”. If this happens open your file explorer and navigate into the project Assets > Plugins > Android and delete the
Thanks for following along, feel free to leave a comment below!
- The complete API documentation is available in the Document Center.
- For technical support, submit a ticket using the Agora Dashboard.