facebook twitter hatena line email

「Unity/Agora/voicechat community」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(デモから音声通話サンプル作成)
 
(同じ利用者による、間の24版が非表示)
行1: 行1:
 +
[[Unity/Agora/voicechat community/インストール]]
  
=agoraコミュニティ側=
+
[[Unity/Agora/voicechat community/ログ]]
==sdkはどれを使っている==
+
unitysdkではなく、websdkを使ってる。
+
Assets/WebGLTemplates/AgoraTemplate2020/AgoraWebSDK
+
  
==agoraインストール==
+
[[Unity/Agora/voicechat community/デモ通話]]
#https://github.com/AgoraIO-Community/Agora_Unity_WebGL をDL
+
#Assets/AgoraEngine/Demo/SceneHomeを開く
+
#GameControllerのInspectorを開きAppIDを入力する
+
#Unityメインメニュー/File/BuildSettings/PlayerSetttings/WebGL/WebGLTemplateをAgoraTemplete2020
+
#Unityメインメニュー/File/BuildSettings/PlayerSetttings/SceneInBuildのSceneHomeとSceneHellowVideoに、チェックを追加
+
#WebGLでビルドすると、htmlがブラウザで開くのでJoinを確認
+
  
===agoraSdkCWrapperなエラーが出る場合===
+
[[Unity/Agora/voicechat community/デモ画面共有]]
詳細
+
DllNotFoundException: agoraSdkCWrapper assembly:<unknown assembly> type:<unknown type> member:(null)
+
UnityEditorで表示するとこのエラーが出る。WebGLでビルドしてブラウザで表示すると良い。
+
==デモ版ソース解析==
+
*AgoraEngine/Demo/ButtonHandler.csに、ボタンの挙動が、記述されてる
+
*AgoraEngine/Demo/TestHome.csが、テストロジック処理が、記述されてる
+
*TestHome.onJoinButtonClickedが、動画音声処理
+
*TestHome.onJoinAudienceが、配信受け取る(Audience)処理
+
*TestHome.onJoinAudienceが通信周りロジック
+
*AssetsAgoraEngine/Prefabs/AgoraEventHandlerを、ロードSceneに追加しておく。
+
*Hostボタンのオンオフ処理は、Assets/AgoraEngine/Demo/TestHome.onJoinAudience.csのGameObject.Find("RoleButton")とAssets/API-Example/tools/ToggleStateButton.csあたり。Audience表示されてる時Broadcastされ、Host表示のときに、Audienceとなっている様子。
+
*AgoraEngine/Demo/TestHelloUnityVideo.csが通信ロジック周りの処理が、記述されてる
+
  
===動画音声オンオフ===
+
[[Unity/Agora/voicechat community/新画面共有]]
*AgoraEngine/Demo/TestHelloUnityVideo.csの以下部分
+
<pre>
+
AudioVideoState.pubAudio = av.togglePubAudio.isOn;
+
AudioVideoState.pubVideo = av.togglePubVideo.isOn;
+
AudioVideoState.subAudio = av.toggleSubAudio.isOn;
+
AudioVideoState.subVideo = av.toggleSubVideo.isOn;
+
</pre>
+
===音声オフだと===
+
こちらの処理になる。
+
gameController.onJoinButtonClicked(false);
+
  
===Android時の権限追加===
+
[[Unity/Agora/voicechat community/token取得]]
<pre>
+
#if (UNITY_2018_3_OR_NEWER && UNITY_ANDROID)
+
ArrayList permissionList = new ArrayList();
+
permissionList.Add(Permission.Microphone);       
+
permissionList.Add(Permission.Camera); 
+
        foreach(string permission in permissionList)
+
        {
+
            if (!Permission.HasUserAuthorizedPermission(permission))
+
            {               
+
Permission.RequestUserPermission(permission);
+
}
+
        }
+
#endif
+
</pre>
+
 
+
===ビルド時の"Pointer_stringify"のエラー表示===
+
以下エラーが出るが、動作に問題ない。
+
The JavaScript function 'Pointer_stringify(ptrToSomeCString)' is obsoleted and will be removed in a future Unity version. Please call 'UTF8ToString(ptrToSomeCString)' instead.
+
printErr @ webgl_project_audio.loader.js:1
+
 
+
==デモから音声通話サンプル作成==
+
AudioScene.unityを追加して、AudioScene.csを作成して、AudioScene.unityのMainCameraへ追加
+
<pre>
+
using UnityEngine;
+
 
+
public class AudioScene : 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
+
    }
+
}
+
</pre>
+
Assets/AgoraEngine/Demo/AudioVideoState.csのフラグを追加
+
<pre>
+
public class AudioVideoStates
+
{
+
    public bool subAudio = true;
+
    public bool subVideo = false;
+
    public bool pubAudio = true;
+
    public bool pubVideo = false;
+
}
+
</pre>
+
#Assets/AgoraEngine/Demo/TestHelloUnityVideo.csのjoin()内の、SetupInitState();を削除
+
#AssetsAgoraEngine/Prefabs/AgoraEventHandlerを、ロードSceneに追加しておく。
+
 
+
===切断処理===
+
<pre>
+
public void Disconnect()
+
{
+
    if (!ReferenceEquals(app, null))
+
    {
+
        app.leave(); // leave channel
+
        app.unloadEngine(); // delete engine
+
        app = null; // delete app
+
    }
+
}
+
</pre>
+
===ビルド後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を再起動する
+
 
+
==デモから画面共有サンプル作成==
+
===サンプルソース解析===
+
*SceneFuncTests.unityのApi_testHelperのGameObjectのFunctionalTest/DevDemo/Test/DVC_ShareScreen.csが、画面共有ソース
+
*TestHome.csのonJoinButtonClicked()からシーン移動している
+
*FunctionalTest/DevDemo/SceneHome2のボタンで、移動できる。
+
 
+
===以下"SceneFuncTests"がロードできないというエラーとなる場合===
+
以下エラーとなる場合
+
'SceneFuncTests' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
+
To add a scene to the build settings use the menu File->Build Settings...
+
PlayerSettingのSceneInBuildにSceneFuncTests.unityを追加すると良い。
+

2023年1月14日 (土) 00:06時点における最新版

Unity/Agora/voicechat community/インストール

Unity/Agora/voicechat community/ログ

Unity/Agora/voicechat community/デモ通話

Unity/Agora/voicechat community/デモ画面共有

Unity/Agora/voicechat community/新画面共有

Unity/Agora/voicechat community/token取得