서버 - agora voice chat 기능 추가 도전
Closed this issue · 2 comments
목적
다음과 같음.
작업 상세 내용
- [ ]
참고 사항
- [ ]
https://www.youtube.com/watch?v=WIC7TfScm_M&t=1005s
Agora 튜토리얼 중에 오류가 나서 질문하고 싶습니다!
using UnityEngine;
using agora_gaming_rtc;
using UnityEngine.UI;
public class AgoraTest: MonoBehaviour
{
public string AppID;
public string ChannelName;
VideoSurface myView;
VideoSurface remoteView;
IRtcEngine mRtcEngine;
void Awake()
{
SetupUI();
}
void SetupUI(){
GameObject go = GameObject.Find("mine");
myView = go.AddComponent<VideoSurface>();
go = GameObject.Find("LeaveButton");
go?.GetComponenet<Button>()?.onClick.AddListener(Leave);
go = GameObject.Find("JoinButton");
go?.GetComponenet<Button>()?.onClick.AddListener(Join);
}
void Start()
{
SetupAgora();
}
void SetupAgora()
{
mRtcEngine = IRtcEngine.GetEngine(AppID);
mRtcEngine.OnUserJoined = OnUserJoined;
mRtcEngine.OnUserOffline = OnUserOffline;
mRtcEngine.OnJoinChannelSuccess = OnJoinChannelSuccessHandler;
mRtcEngine.OnLeaveChannel = OnLeaveChannelHandler;
}
void Join()
{
mRtcEngine.EnableVideo();
mRtcEngine.EnableVideoObserver();
myView.SetEnable(true);
mRtcEngine.JoinChannel(ChannelName, "", 0);
}
void Leave()
{
mRtcEngine.LeaveChannel();
mRtcEngine.DisableVideo();
mRtcEngine.DisableVideoObserver();
}
void OnJoinChannelSuccessHandler(string channelName, uint uid, int elapsed)
{
//join successfully
Debug.LogFormat("Joined channel {0} successfully, my uid is {1}", channelName, uid);
}
void OnLeaveChannelHandler(RtcStats stats)
{
myView.SetEnable(false);
if(remoteView != null)
{
remoteView.SetEnable(false);
}
}
void OnUserJoined(uint uid, int elapsed)
{
//원격 사용자가 들어오는 경우
if(remoteView == null)
{
remoteView = GameObject.Find("others").AddComponent<VideoSurface>();
}
remoteView.SetForUser(uid);
remoteView.SetEnable(true);
remoteView.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
remoteView.SetGameFps(30);
}
void OnUserOffline(uint uid, USER_OFFLINE_REASON reason)
{
remoteView.SetEnable(false);
}
void OnApplicationQuit()
{
if(mRtcEngine!=null)
{
IRtcEngine.Destroy();
mRtcEngine = null;
}
}
}
Assets\Scenes\AgoraTest.cs(28,16): error CS1061: 'GameObject' does not contain a definition for 'GetComponenet' and no accessible extension method 'GetComponenet' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)
CS1061이 뜨는데 GameObject에 GetComponent라는 method가 없다는 뜻 같습니다. 반면 여러 코드를 찾아봐도 GameObject.GetComponent를 사용하고 있고
https://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html
유니티 Docs에서도 이를 찾아볼 수 있는데 어떤 점이 문제인걸까요?
voice chat이 아니라 video chat이었나요? 일단 voice 챗은 제가 하기로 했으니 close 하겠습니다!!