tencent cloud

Tencent Real-Time Communication

お知らせ・リリースノート
製品アップデート情報
Tencent Cloudオーディオビデオ端末SDKの再生アップグレードおよび承認チェック追加に関するお知らせ
TRTCアプリケーションのサブスクリプションパッケージサービスのリリースに関する説明について
製品の説明
製品概要
基礎概念
製品の機能
製品の強み
ユースケース
性能データ
購入ガイド
Billing Overview
無料時間の説明
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
課金に関するよくあるご質問
Refund Instructions
初心者ガイド
Demo体験
Call
コンポーネントの説明(TUICallKit)
Activate the Service
Run Demo
クイック導入
オフライン通知
Conversational Chat
クラウドレコーディング(TUICallKit)
AI Noise Reduction
インターフェースのカスタマイズ
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
公開ログ
よくある質問
ライブ配信
Billing of Video Live Component
Overview
Activating the Service (TUILiveKit)
Demo のクイックスタート
No UI Integration
UI Customization
Live Broadcast Monitoring
Video Live Streaming
Voice Chat Room
Advanced Features
Client APIs
Server APIs
Error Codes
Release Notes
FAQs
RTC Engine
Activate Service
SDKのダウンロード
APIコードサンプル
Usage Guidelines
クライアント側 API
高度な機能
RTC RESTFUL API
History
Introduction
API Category
Room Management APIs
Stream mixing and relay APIs
On-cloud recording APIs
Data Monitoring APIs
Pull stream Relay Related interface
Web Record APIs
AI Service APIs
Cloud Slicing APIs
Cloud Moderation APIs
Making API Requests
Call Quality Monitoring APIs
Usage Statistics APIs
Data Types
Appendix
Error Codes
コンソールガイド
アプリケーション管理
使用統計
監視ダッシュボード
開発支援
Solution
Real-Time Chorus
よくあるご質問
課金関連問題
機能関連
UserSig関連
ファイアウォールの制限の対応関連
インストールパッケージの圧縮に関するご質問
AndriodおよびiOS関連
Web端末関連
Flutter関連
Electron関連
TRTCCalling Web関連
オーディオビデオ品質関連
その他のご質問
旧バージョンのドキュメント
TUIRoom(Web)の統合
TUIRoom (Android)の統合
TUIRoom (iOS)の統合
TUIRoom (Flutter)の統合
TUIRoom (Electron)の統合
TUIRoom APIのクエリー
クラウドレコーディングと再生の実現(旧)
Protocols and Policies
セキュリティコンプライアンス認証
セキュリティホワイトペーパー
情報セキュリティの説明
Service Level Agreement
Apple Privacy Policy: PrivacyInfo.xcprivacy
TRTC ポリシー
プライバシーポリシー
データ処理とセキュリティ契約
用語集

Unity

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-08-04 17:09:22
This article will introduce how to quickly integrate the Unity RTC Engine and implement a basic audio and video call.

Environment preparations

Unity 2022.3.13f1.
Currently supports Android, iOS, Windows, Mac platforms.
Unity needs to include Android Build Support, iOS Build Support, Windows Build Support and MacOs Build Support modules.
For iOS development, please make sure your project has a valid developer signature.

Integration guideline

Step 1. Import TRTC SDK

1. Open Unity and create your own Unity program.
2. Download the Unity SDK and unzip the SDK library containing the following files:

3. Copy the files Plugins and TRTCSDK in the Assets directory of the decompressed SDK to the Assets file directory of your project.

Step 2. Configure project

iOS / Mac / Android need to add requests for camera and mic permissions in the project:
iOS/Mac
Android
1. Open the Player settings interface of Project Settings in the Unity project.
2. Add the description statements of the corresponding permission application to Camera Usage Description and Microphone Usage Description of the MAC/iOS platform respectively as shown in the following figure.

1. Open the AndroidManifest.xml file in your project.
2. Add the following permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.autofocus" />

Step 3. Create TRTC instance

1. Import TRTC namespace.
using trtc;
2. Inherit ITRTCCloudCallback and override ITRTCCloudCallback method to declare and define TRTCCloud events.
public class AppExample : MonoBehaviour,
ITRTCCloudCallback {
private ITRTCCloud mTRTCCloud; // Declare the TRTCCloud member variable

#region ITRTCCloudCallback
public:
public void onError(TXLiteAVError errCode, String errMsg, IntPtr arg) {} // Listen for the 'onError' event
public void onWarning(TXLiteAVWarning warningCode, String warningMsg, IntPtr arg) {} // Listen for the 'onWarning' event
public void onEnterRoom(int result) {} // Listen for the result of 'onEnterRoom' event
public void onExitRoom(int reason) {} // Listen for the result of 'onExitRoom' event
// to do other event.........
#endregion
}
3. Call the interface to obtain the TRTC instance.
mTRTCCloud = ITRTCCloud.getTRTCShareInstance();
4. Call the addCallback interface to add listeners for TRTCCloud events.
mTRTCCloud.addCallback(this);

Step 4. Enter the room

1. Set the entry parameter TRTCParams and call enterRoom to successfully enter the room.
Parameter
Type
Description
sdkAppId
UInt32
The sdkAppId of the audio and video application you created in TRTC Console.
userId
String
User ID specified by you.
userSig
String
User signature, refer to UserSig.
roomId
UInt32
Room ID specified by you, usually a unique room ID.
For more detailed parameter descriptions, please refer to the interface document enterRoom.
TRTCParams trtcParams = new TRTCParams();
trtcParams.sdkAppId = 1400xxxxx;
trtcParams.roomId = 345;
trtcParams.userId = "123";
trtcParams.userSig = "";
TRTCAppScene scene = TRTCAppScene.TRTCAppSceneLIVE;
mTRTCCloud.enterRoom(ref trtcParams, scene);

public void onEnterRoom(int result) {} // Listen for the result of 'onEnterRoom' event

Step 5. Turn on/off Camera

1. Create a component RawImage: videoView in the Unity project as the value of the startLocalPreview interface parameter view.
2. Before calling the interface startLocalPreview to open the camera preview, you can set the local preview rendering parameters by calling the interface setLocalRenderParams.
// Set local preview rendering parameters
private TRTCRenderParams renderParams = new TRTCRenderParams();
renderParams.fillMode = TRTCVideoFillMode.TRTCVideoFillMode_Fit;
renderParams.mirrorType = TRTCVideoMirrorType.TRTCVideoMirrorType_Disable;
renderParams.rotation = TRTCVideoRotation.TRTCVideoRotation0;
mTRTCCloud.setLocalRenderParams(renderParams);

// Local preview of the content captured by the front camera
mTRTCCloud.startLocalPreview(true, videoView);

// Local preview of the content captured by the rear camera
mTRTCCloud.startLocalPreview(false, videoView);
3. Call stopLocalPreview to close the camera preview and stop pushing local video information.
mTRTCCloud.stopLocalPreview();

Step 6. Turn on/off Microphone

1. Call the startLocalAudio to turn on microphone capture. Select one of the following sound Quality parameters according to your requirements.
// Enable microphone acquisition and set the current scene to: Voice mode
// For high noise suppression capability, strong and weak network resistance
mTRTCCloud.startLocalAudio(TRTCAudioQuality.TRTCAudioQualitySpeech);
// Enable microphone acquisition, and set the current scene to: Music mode
// For high fidelity acquisition, low sound quality loss, recommended to use with professional sound cards
mTRTCCloud.startLocalAudio(TRTCAudioQuality.TRTCAudioQualityMusic);
2. Call stopLocalAudio to turn off microphone collection and stop pushing local audio information.
mTRTCCloud.stopLocalAudio()

Step 7. Play/stop Video Streaming

1. Listen for the onUserVideoAvailable before entering the room. When you receive the onUserVideoAvailable(userId, true) notification, it indicates that playable video frames are available for that user's video stream.
public void onUserVideoAvailable(String userId, bool available) {
}
2. Call startRemoteView/stopRemoteView to play or stop the remote video.
mTRTCCloud.startRemoteView(“denny”, TRTCVideoStreamType.TRTCVideoStreamTypeBig, videoView);
// videoView is the RawImage component of Unity
3. Call stopRemoteView to stop playing the remote image.
mTRTCCloud.stopRemoteView(”denny“, TRTCVideoStreamType.TRTCVideoStreamTypeBig); // Stop playing denny's video
mTRTCCloud.stopAllRemoteView(true); // Mute all remote users

Step 8. Play/stop Audio Streaming

Call muteRemoteAudio to mute or unmute the remote sound.
// Mute
mTRTCCloud.muteRemoteAudio("denny", true); // Mute denny
mTRTCCloud.muteAllRemoteAudio(true); // Mute all remote users
// Unmute
mTRTCCloud.muteRemoteAudio("denny", false); // Unmute denny
mTRTCCloud.muteAllRemoteAudio(false); // Unmute all remote users

Step 9. Exit the room

1. Call exitRoom to exit the current room.
mTRTCCloud.exitRoom();
2. TRTC SDK will notify you through the onExitRoom callback event after exiting the room.
public void onExitRoom(int reason) {} // Listen for the result of 'onExitRoom' event

FAQs

API Reference at API Reference.

Contact us

If you have any suggestions or feedback, please contact info_rtc@tencent.com.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック