TRTC Unity
This demo 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/audio effects
For details about the APIs, please see Unity > Overview.
If you have questions about the integration, contact us via QQ at 788910197.
Environment Requirements
- 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
- In the TRTC console, select Development Assistance > Demo Quick Run.
- Click Start Now, enter an application name such as
TestTRTC
, and click Create Application.
Step 2. Download the SDK and source code
- Download the SDK and demo source code.
- Click Next. You can open the project with Unity, or copy
TRTCUnitySDK/Assets/TRTCSDK/SDK
in the SDK ZIP file to theAssets
directory of your project. - Find and open
Assets/TRTCSDK/Demo/Tools/GenerateTestUserSig.cs
. - 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.
Android
- Open Unity Editor, go to File > Build Settings, and select Android for Platform.
- Connect to a real Android device and click Build And Run to run the demo.
- 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.
iOS
- Open Unity Editor, go to File > Build Settings, and select iOS for Platform.
- Connect to a real iPhone, and click Build And Run. You need to select a new folder to save your iOS build. When the build is completed, the folder containing the Xcode project will open in a new window.
- Expand Link Binary with Libraries, click +, and add the dependent library
libresolv.tbd
. - Expand Other Linker Flags and add
-ObjC
.
Windows
- Open Unity Editor, go to File > Build Settings, and select PC, Mac & Linux Standalone for Platform, and Windows for Target Platform.
- Click Build And Run to run the demo.
macOS
- Open Unity Editor, go to File > Build Settings, and select PC, Mac & Linux Standalone for Platform, and macOS for Target Platform.
- Click Build And Run to run the demo.
- To use the simulator feature of Unity Editor, install Device Simulator, and click Window > General > Device Simulator.
Demo UI
- 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 the APIs, please see Unity > Overview.
- 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