Only  $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Only $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Grab It Now 
RTC Engine
Overview
  • Web
    • Demo Quick Run
    • SDK Quick Start
    • Basic Features
      • Screen Sharing
      • Live Streaming
      • Media Device
      • Audio Volume
      • Set Encoding Profile
      • Detect Network Quality
      • Detect Capabilities
    • Advance Features
      • Enable AI Denoiser
      • Enable Audio Mixer
      • Enable Watermark
      • Enable Beauty and Effects
      • SEI Message
      • Custom Capturing and Rendering
    • Best Practices
      • Optimize Multi-Person Video Calls
      • Handle Autoplay Restriction
      • Handle Firewall Restriction
    • API List
    • Released Notes
    • Supported Platforms
    • Web FAQs
  • Android
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Newwork Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCStatistics
      • TRTCCloudListener
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Solution
      • Real-Time Chorus (TUIKaraoke)
        • Quick Integration
        • Implementation Steps
        • Song Synchronization
        • Lyric Synchronization
        • Vocal Synchronization
        • Mixing Stream Solution
        • TRTCKaraoke APIs
        • FAQs
    • Release Notes
  • iOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
    • Solution
      • Quick Integration
      • Implementation Steps
      • Song Synchronization
      • Lyric Synchronization
      • Vocal Synchronization
      • Mixing Stream Solution
      • TRTCKaraoke APIs
      • FAQs
    • Release Notes
  • macOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
      • Release Notes
    • Release Notes
  • Windows
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • ITRTCCloud
      • ITRTCStatistics
      • TRTCCloudCallback
      • ITXAudioEffectManager
      • ITXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Release Notes
  • Electron
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Flutter
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Unity
    • Integration
      • 1.API Examples
      • 2Importing the SDK
    • Client APIs
      • Overview
      • Error Codes
  • Qt
    • Integration
      • 1.Importing the SDK
  • Overview
    • Overview
  • Concepts
  • Features
  • Performance Statistics
  • Pricing
    • RTC-Engine Packages
    • Billing of On-Cloud Recording
    • Billing of MixTranscoding and Relay to CDN
    • Billing Explanation for Subscription Package Duration
    • Billing of Monitoring Dashboard
    • Free Minutes
    • Pay-As-You-Go
  • Tencent RTC Quickplay: Experience Ultimate Real-Time Audio and Video Interaction!
  • FAQs
    • FAQs for Beginners
    • Migration Guide
      • Twilio Video to Tencent RTC
      • Billing
      • Features
      • UserSig
      • Firewall Restrictions
      • How to Downsize Installation Package
      • TRTCCalling for Web
      • Audio and Video Quality
      • Others
RTC Engine

1.API Examples

This document shows you 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
Note
For details about the APIs and their parameters, see 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 later
A valid developer signature for your project

Directions

Step 1. Create an application

1. Log in to the TRTC console overview page, click Create Application.
2. In the popup page, select RTC Engine, enter the application name, and then click Create.




Step 2. Get your SDKAppId and SecretKey

After your application created, you can get your SDKAppID and SDKSecretKey on Basic informaction. SDKAppID and SDKSecretKey is needed for running demo.




Step 3. Download the sample code

1. Go to GitHub to download the SDK and demo source code.
git clone https://github.com/LiteAVSDK/TRTC_Unity.git
2. The steps to import SDK can refer to Unity SDK import.

Step 4. Configure the project

1. Open the file downloaded previously, find and open TRTC-Simple-Demo/Assets/TRTCSDK/Demo/Tools/GenerateTestUserSig.cs, and set the following parameters:
SDKAPPID: A placeholder by default. Set it to the actual SDKAppID.
SDKSECRETKEY: A placeholder by default. Set it to the actual key.
Note
The method for generating UserSig described in this document involves configuring SDKSECRETKEY in the client code. In this method, SDKSECRETKEY may be easily decompiled and reversed, and if your key is disclosed, attackers can steal your Tencent Cloud traffic. Therefore, this method is only suitable for the local execution and debugging of TRTC-Simple-Demo.
The best practice is to integrate the calculation code of UserSig into your server and provide an application-oriented API. When UserSig is needed, your application can send a request to your server for a dynamic UserSig. For more information, see How do I calculate UserSig during production?.

Step 5. Compile and run the demo

Android

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.

iOS

1. Open the TRTC build and configuration tool (from the menu at the top).
2. Click Build & Configure iOS to generate a project.


3. Open the project generated (Unity-iPhone.xcodeproj) with Xcode.
4. Download the underlying TRTC SDK. Click General, select Frameworks, Libraries, and Embedded Content, click + at the bottom to add the dynamic libraries required – FFmpeg.xcframework and SoundTouch.xcframework, and click Embed & Sign.


5. Connect to a real iOS device to debug the project.

Windows

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.

macOS

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