tencent cloud

Tencent Real-Time Communication

소식 및 공지 사항
제품 업데이트
Tencent Cloud 오디오/비디오 단말 SDK 재생 업그레이드 및 권한 부여 인증 추가
TRTC 월간 구독 패키지 출시 관련 안내
제품 소개
제품 개요
기본 개념
제품 기능
제품 장점
응용 시나리오
성능 데이터
구매 가이드
Billing Overview
무료 시간 안내
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
과금 FAQ
Refund Instructions
신규 사용자 가이드
Demo 체험
Call
개요(TUICallKit)
Activate the Service
Run Demo
빠른 통합(TUICallKit)
오프라인 푸시
Conversational Chat
온클라우드 녹화(TUICallKit)
AI Noise Reduction
UI 사용자 정의
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
릴리스 노트
FAQs
라이브 스트리밍
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 클라이언트 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
FAQs
과금 개요
기능 관련
UserSig 관련
방화벽 제한 처리
설치 패키지 용량 축소 관련 질문
Andriod 및 iOS 관련
Web 관련
Flutter 관련
Electron 관련
TRTCCalling Web 관련
멀티미디어 품질 관련
기타 질문
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.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백