tencent cloud

Feedback

Last updated: 2022-09-26 11:37:57
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
explain
For details about API features and parameters, please see Client APIs > Unity > Overview.
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

Android
iOS
Windows
macOS
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.
1. Open Unity Editor, go to File > Build Settings, and select iOS for Platform.


2. 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.
1. Open Unity Editor, go to File > Build Settings, and select PC, Mac & Linux Standalone for Platform and Windows for Target Platform.


2. Click Build And Run to run the demo.
1. Open Unity Editor, go to File > Build Settings, and select PC, Mac & Linux Standalone for Platform, and macOS for Target Platform.


2. Click Build And Run to run the demo.
3. To use the simulator feature of Unity Editor, you must install Device Simulator Package.
4. Click Windows > General > Device Simulator.




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.
explain
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

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support