nimeet Docs
中文

Unity SDK Guide

Unity package install, join, render and events.

Interface sections generated from the public SDK definitions

Version v1.1.0 · Updated 2026-10-26 · revision 1

The Unity SDK has the C# RtcEngine + IRtcEngineEventHandler shape with capitalized method names (Initialize, JoinChannel, OnUserJoined) — the same as the Agora Unity reference version.

Prerequisites

  • Unity 2022.3 LTS+ (IL2CPP or Mono).
  • Platform permissions: CAMERA/RECORD_AUDIO on Android, a usage description on iOS, the system camera permission on Windows/macOS.
  • An appId and a token service (see Enable Services and Get Credentials).

Installation

text
Planned distribution:
  1) UPM: add "com.nimeet.rtc": "file:../ni-meet/sdk/unity" to Packages/manifest.json
  2) or import the .unitypackage (Assets/Nimeet/Rtc)
Unity SDK installation and version information follow the published package; the examples on this page use the public interface.

Get a token

The game backend issues the token; the Unity client only receives a string. Do not write the App Certificate into the client. Production advice: hand out a short-lived token at login and renew it against the same backend inside OnTokenPrivilegeWillExpire.

Join a channel

csharp
using Nimeet.Rtc;

public class MeetingController : MonoBehaviour, IRtcEngineEventHandler
{
    private IRtcEngine engine;

    void Start()
    {
        engine = RtcEngine.CreateAgoraRtcEngine();
        var context = new RtcEngineContext { appId = AppConfig.AppId, eventHandler = this };
        engine.Initialize(context);
        engine.SetChannelProfile(ChannelProfileType.ChannelProfileLiveBroadcasting);
        engine.EnableVideo();
        engine.StartPreview();

        var options = new ChannelMediaOptions
        {
            clientRoleType = ClientRoleType.ClientRoleBroadcaster,
            autoSubscribeAudio = true,
            autoSubscribeVideo = true,
        };
        engine.JoinChannel(AppConfig.RtcToken, "weekly-sync", 10001, options);
    }

    public void OnJoinChannelSuccess(RtcConnection connection, int elapsed) => Debug.Log("joined");
    public void OnUserJoined(RtcConnection connection, int remoteUid, int elapsed) { }
    public void OnUserOffline(RtcConnection connection, int remoteUid, UserOfflineReasonType reason) { }
    public void OnTokenPrivilegeWillExpire(string token) { engine.RenewToken(FetchFreshToken()); }
    public void OnError(int err, string msg) => Debug.LogError($"rtc {err}: {msg}");

    void OnDestroy() => RtcEngine.Destroy();
}

Publishing and subscribing

csharp
engine.MuteLocalAudioStream(true);
engine.MuteLocalVideoStream(true);
engine.EnableLocalVideo(false);
engine.UpdateChannelMediaOptions(options);

Screen sharing: GetScreenCaptureSources enumerates sources → StartScreenCaptureByDisplayId / StartScreenCaptureByWindowId; in Unity the shared picture is usually rendered into a RawImage (texture callback) rather than a VideoSurface.

Events

IRtcEngineEventHandler is implemented explicitly in C#: OnJoinChannelSuccess, OnUserJoined, OnUserOffline, OnFirstRemoteVideoDecoded, OnTokenPrivilegeWillExpire, OnError, OnConnectionStateChanged.

Error handling

  • Synchronous methods return int; 0 means success and a negative value is an Agora error number;
  • Asynchronous errors arrive through OnError;
  • Unimplemented capabilities return -4 (ERR_NOT_SUPPORTED).

Troubleshooting

SymptomCauseHandling
Crash after an IL2CPP buildThe native library did not make it into the packageCheck that Plugins/<platform> contains the matching ABI
Fine in the editor, black screen on devicePermissions were not requestedRequest the camera/microphone on the first launch on device
Touching the UI inside a callback errorsNot on the main threadQueue the work and handle it in Update()
The picture is upside down on AndroidFront-camera mirroringAdjust it with VideoCanvas.mirrorMode
Low frame rateEncoding parameters are too highLower the resolution/frame rate in SetVideoEncoderConfiguration

Next steps

Platform information

Itemvalue
PlatformUnity(C#)
LanguageC#
SDK packageNimeet.Rtc
Interface version4.6.2
Compatible Agora APIAgora unity API

The public interfaces are aligned with the Agora unity API; installation and runtime requirements are listed under Prerequisites above.

Availability

This platform's SDK: Generally available. The examples use the public API; runtime capability follows the published SDK package.

join-channel flow

The method names, parameter types and return values match the API reference for the same platform. Where a method has several overloads, the most common one is shown here; see the API reference for all overloads.

StepInterfaceMethodOverload count
subscribe to remote mediaIBaseSpatialAudioEngineMuteRemoteAudioStream1
Create instance / initializeILocalSpatialAudioEngineInitialize1
Renew the TokenIMusicContentCenterRenewToken1
enable video and local previewIRtcEngineEnableVideo1
Join a channelIRtcEngineJoinChannel2
Leave a channelIRtcEngineLeaveChannel2
Channel scenariosIRtcEngineSetChannelProfile1
switch rolesIRtcEngineSetClientRole2
bind the local videoIRtcEngineSetupLocalVideo1
typescript
MuteRemoteAudioStream(uid: uint, mute: bool): int
Initialize(): int
RenewToken(token: string): int
EnableVideo(): int
JoinChannel(token: string, channelId: string, info?: string, uid?: uint): int
LeaveChannel(): int
SetChannelProfile(profile: CHANNEL_PROFILE_TYPE): int
SetClientRole(role: CLIENT_ROLE_TYPE): int
SetupLocalVideo(canvas: VideoCanvas): int

Events and callbacks

This SDK has no event callbacks.

Error codes

Constantvalue
ERR_ABORTED20
ERR_ADM_GENERAL_ERROR1005
ERR_ADM_INIT_PLAYOUT1008
ERR_ADM_INIT_RECORDING1011
ERR_ADM_START_PLAYOUT1009
ERR_ADM_START_RECORDING1012
ERR_ADM_STOP_PLAYOUT1010
ERR_ADM_STOP_RECORDING1013
ERR_ALREADY_IN_USE19
ERR_BITRATE_LIMIT115
ERR_BUFFER_TOO_SMALL6
ERR_CLIENT_IS_BANNED_BY_SERVER123
ERR_CONNECTION_INTERRUPTED111
ERR_CONNECTION_LOST112
ERR_DATASTREAM_DECRYPTION_FAILED122
ERR_DECRYPTION_FAILED120
ERR_ENCRYPTED_STREAM_NOT_ALLOWED_PUBLISH130
ERR_FAILED1
ERR_INIT_NET_ENGINE21
ERR_INVALID_APP_ID101
ERR_INVALID_ARGUMENT2
ERR_INVALID_CHANNEL_NAME102
ERR_INVALID_STATE8
ERR_INVALID_TOKENnull
ERR_INVALID_USER_ACCOUNT134
ERR_INVALID_USER_ID121
ERR_JOIN_CHANNEL_REJECTED17
ERR_LEAVE_CHANNEL_REJECTED18
ERR_LOAD_MEDIA_ENGINE1001
ERR_NOT_INITIALIZED7
ERR_NOT_IN_CHANNEL113
ERR_NOT_READY3
ERR_NOT_SUPPORTED4
ERR_NO_PERMISSION9
ERR_NO_SERVER_RESOURCES103
ERR_OK0
ERR_PCMSEND_BUFFEROVERFLOW201
ERR_PCMSEND_FORMAT200
ERR_REFUSED5
ERR_RESOURCE_LIMITED22
ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED119
ERR_SIZE_TOO_LARGE114
ERR_STREAM_MESSAGE_TIMEOUT117
ERR_TIMEDOUT10
ERR_TOKEN_EXPIRED109
ERR_TOO_MANY_DATA_STREAMS116
ERR_VDM_CAMERA_NOT_AUTHORIZED1501
IRtcEnginenull

the platform REST layer uses REST error codes;the SDK layer maps connection/authentication failures to Agora error numbers, for the mapping table see SDK error identifiers per platform。

Generated by the documentation build pipeline · 2026-10-31 01:24:02 UTC · Documentation center v1.1.0.

Content follows the public API definitions.

ni-meet is a self-hosted RTC PaaS with a LiveKit-based media plane (Apache-2.0) and an Agora-compatible API.