Last updated: 2021-09-29 15:55:43

This document shows how to integrate the TRTC SDK in Unity to enable audio/video calls in games.

The demo includes the following features:

  • Room entry/exit
  • Custom video rendering
  • Device management and music/voice effects
Note:

  • Unity 2020.2.1f1c1 is recommended.
  • Supported platforms: Android, iOS, Windows, macOS (alpha testing)
  • Modules required: Android Build Support, iOS Build Support, Windows Build Support, MacOS Build Support
  • If you are developing for iOS, you also need:
    • Xcode 11.0 or above
    • A valid developer signature for your project

Directions

Step 1. Create an application

  1. Log in to the TRTC console and select Development Assistance > Demo Quick Run.
  2. Enter an application name such as TestTRTC and click Create.

Step 2. Download the SDK and source code

  1. Download the SDK and demo source code.

  2. Click Next. You can open the project with Unity, or copy TRTCUnitySDK/Assets/TRTCSDK/SDK in the SDK ZIP file to the Assets directory of your project.

  3. Find and open Assets/TRTCSDK/Demo/Tools/GenerateTestUserSig.cs.

  4. Set parameters in GenerateTestUserSig.cs as follows:

    • SDKAPPID: `0` by default. Set it to the actual `SDKAppID`.
    • SECRETKEY: left empty by default. Set it to the actual key.

Step 3. Compile and run

  1. Open Unity Editor, go to File > Build Settings, and select Android for Platform.
  2. Connect to a real Android device and click Build And Run to run the demo.
  3. Call enterRoom first and go on to test other APIs. The data display window shows whether the call is successful, and the other window displays the callback information.

Demo

The demo integrates most of the APIs launched so far, which can be used for testing and as reference for API calls. For more information about APIs, see Client APIs > Unity > Overview.

Note:

The UI of the latest version of the demo may look different.

Directory Structure

├─Assets
├── Editor                        // Unity Editor script
│   ├── BuildScript.cs            // Unity Editor build menu
│   ├── IosPostProcess.cs         // Script for building iOS application in Unity Editor
├── Plugins
│   ├── Android                   
│   │   ├── AndroidManifest.xml   //Android configuration file
├── StreamingAssets               // Audio/video stream files for the Unity demo
├── TRTCSDK
   ├── Demo                      // Unity demo
   ├── SDK                       // TRTC SDK for Unity
       ├── Implement             // Implementation of TRTC SDK for Unity
       ├── Include               // Header files of TRTC SDK for Unity
       └── Plugins               // Underlying implementation of TRTC SDK for Unity for different platforms