「Unity/Agora/voicechat community/デモ通話」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「 ==デモから音声通話サンプル作成== VoiceScene.unityを追加して、VoiceScene.csを作成して、VoiceScene.unityのMainCameraへ追加 <pre> using UnityE...」) |
(→AgoraTemplate2020が適用されない) |
||
| 行59: | 行59: | ||
*Assets/WebGLTemplates/AgoraTemplate2020があるか確認する。 | *Assets/WebGLTemplates/AgoraTemplate2020があるか確認する。 | ||
*PCを再起動する | *PCを再起動する | ||
| + | |||
| + | ==="Client already in connecting/connected state"エラーが出る時=== | ||
| + | 詳細 | ||
| + | AgoraRTCException: AgoraRTCError INVALID_OPERATION: [client-fa598] Client already in connecting/connected state | ||
| + | joinを2回やってたりするとでるので、joinフラグか何かをもたせて、2度処理などしないように。 | ||
2022年11月24日 (木) 18:26時点における最新版
目次
デモから音声通話サンプル作成
VoiceScene.unityを追加して、VoiceScene.csを作成して、VoiceScene.unityのMainCameraへ追加
using UnityEngine;
public class VoiceScene : MonoBehaviour
{
void Start()
{
#if !UNITY_EDITOR && UNITY_WEBGL
string AppID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
TestHelloUnityVideo app = null;
// create app if nonexistent
if (ReferenceEquals(app, null))
{
app = new TestHelloUnityVideo(); // create app
app.loadEngine(AppID); // load engine
}
string ChannelName = "testchannel";
bool enableVideo = false;
bool muted = false;
app.join(ChannelName, enableVideo, muted);
#endif
}
}
Assets/AgoraEngine/Demo/AudioVideoState.csのフラグを追加
public class AudioVideoStates
{
public bool subAudio = true;
public bool subVideo = false;
public bool pubAudio = true;
public bool pubVideo = false;
}
- Assets/AgoraEngine/Demo/TestHelloUnityVideo.csのjoin()内の、SetupInitState();を削除
- AssetsAgoraEngine/Prefabs/AgoraEventHandlerを、ロードSceneに追加しておく。
切断処理
public void Disconnect()
{
if (!ReferenceEquals(app, null))
{
app.leave(); // leave channel
app.unloadEngine(); // delete engine
app = null; // delete app
}
}
ビルド後html表示時に"NullReferenceException"エラーとなる場合
エラー詳細
webgl_project_audio.framework.js:3 NullReferenceException: Object reference not set to an instance of an object.
Assets/AgoraEngine/Demo/TestHelloUnityVideo.csのjoin()内の、SetupInitState();を削除
AgoraTemplate2020が適用されない
- Assets/WebGLTemplates/AgoraTemplate2020があるか確認する。
- PCを再起動する
"Client already in connecting/connected state"エラーが出る時
詳細
AgoraRTCException: AgoraRTCError INVALID_OPERATION: [client-fa598] Client already in connecting/connected state
joinを2回やってたりするとでるので、joinフラグか何かをもたせて、2度処理などしないように。
