Skip to content

Instantly share code, notes, and snippets.


Rick Cheng icywind

View GitHub Profile
icywind / AgoraApiHandlersImpl.cs
Created Oct 21, 2019
Actual implementation for the Agora SDK event callbacks.
View AgoraApiHandlersImpl.cs
using UnityEngine;
using agora_gaming_rtc;
public class AgoraApiHandlersImpl
private IRtcEngine mRtcEngine;
public AgoraApiHandlersImpl(IRtcEngine engine)
mRtcEngine = engine;
View AgoraDemo_SetupUI.cs
void SetupUI()
GameObject go = GameObject.Find("MyView");
myView = go.AddComponent<VideoSurface>();
go = GameObject.Find("LeaveButton");
go = GameObject.Find("JoinButton");
icywind / AgoraDemo_JoinLeave.cs
Created Aug 24, 2020
Demo Join and Leave implementation
View AgoraDemo_JoinLeave.cs
void Join()
mRtcEngine.JoinChannel(ChannelName, "", 0);
void Leave()
View AgoraDemo_QuickStart.cs
public string AppID;
public string ChannelName;
VideoSurface myView;
VideoSurface remoteView;
IRtcEngine mRtcEngine;
void Awake()
// SetupUI();
View AgoreDemo_Quit.cs
void OnApplicationQuit()
if (mRtcEngine != null)
mRtcEngine = null;
View AgoraDemo_eventHandlers.cs
void OnJoinChannelSuccessHandler(string channelName, uint uid, int elapsed)
// can add other logics here, for now just print to the log
Debug.LogFormat("Joined channel {0} successful, my uid = {1}", channelName, uid);
void OnLeaveChannelHandler(RtcStats stats)
if (remoteView != null)
View AgoraDem_SetupAgora.cs
void SetupAgora()
mRtcEngine = IRtcEngine.GetEngine(AppID);
mRtcEngine.OnUserJoined = OnUserJoined;
mRtcEngine.OnUserOffline = OnUserOffline;
mRtcEngine.OnJoinChannelSuccess = OnJoinChannelSuccessHandler;
mRtcEngine.OnLeaveChannel = OnLeaveChannelHandler;
icywind / AgoraVideoChat_PushVideo.cs
Created Aug 9, 2020
Use external video source to push video frame
View AgoraVideoChat_PushVideo.cs
#region =========== Push Video =================
public const TextureFormat ConvertFormat = TextureFormat.BGRA32;
public const VIDEO_PIXEL_FORMAT PixelFormat = VIDEO_PIXEL_FORMAT.VIDEO_PIXEL_BGRA; // note: RGBA is available from 3.0.1 and on
Texture2D BufferTexture;
bool _isRunning;
IEnumerator CoShareRenderData()
View AgoraVideoChat_CreateUserVideoSurface.cs
private GameObject avatarVideoPrefab;
// Create new image plane to display users in party.
private void CreateUserVideoSurface(uint uid, bool isLocalUser, bool isAvatar)
// Avoid duplicating Local player VideoSurface image plane.
for (int i = 0; i < playerVideoList.Count; i++)
if (playerVideoList[i].name == uid.ToString())
View AvatarViewController.cs
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
public class AvatarViewController : MonoBehaviour
Dropdown EffectDropdown;
GameObject EffectsParent;
You can’t perform that action at this time.