ドキュメント

サポート

Vivox Unity SDK

Vivox Unity SDK

ゲームにサインインする

How to sign in a player to Vivox services.
読み終わるまでの所要時間 1 分最終更新 23日前

Vivox SDK を初期化した後は、そのゲームに割り当てられた Vivox インスタンスにユーザーをサインインさせることができます。 プレイヤーに使用される名前は、Unity AuthenticationId か、Unity Authentication が使用されていない場合は新しい GUID になります。 初期化されたら、
VivoxService.Instance.LoginAsync
メソッドを呼び出して Vivox にサインインします。
  • VivoxService.Instance.LoginAsync
    のオプションの引数は LoginOptions 構造体で、ユーザーの表示名を設定する、テキスト音声変換を有効にする、またはブロックユーザーリストをロードすることができます。
LoginOptions で表示名が設定されると、この名前は参加するチャンネル内のすべてのユーザーに表示されます。ユーザーはこれを DisplayName (VivoxParticipant の結果内) として、
VivoxService.Instance.ParticipantAddedToChannel
または
VivoxService.Instance.ParticipantRemovedFromChannel
から受け取ります。
  • 表示名は現在のセッションでのみ有効で、Vivox ネットワークには保持されません。
  • 表示名の最大長は 127 バイトです。
以下のコードは、サインインプロセスを開始する方法、DisplayName を "Bob" に設定する方法、テキスト音声変換を有効にする方法の例です。
using UnityEngine;using Unity.Services.Vivox;class LogInExample : MonoBehaviour{ . . . async void LoginUserAsync() { // For this example, the VivoxService is initialized. var loginOptions = new LoginOptions() { DisplayName = "Bob", EnableTTS = true }; VivoxService.Instance.LoginAsync(loginOptions) } . . .}
LoginAsync が正常に呼び出されたときにイベントを受け取るために、
VivoxService.Instance.LoggedIn
VivoxService.Instance.LoggedOut
にサブスクライブできます。
以下のコードは、
VivoxService.Instance.LoggedIn
イベントと
VivoxService.Instance.LoggedOut
イベントにサブスクライブする方法と、LoginState の値が異なる関数を処理する方法の例です。
using UnityEngine;using Unity.Services.Vivox;class LoginPropChangeExample : MonoBehaviour{ . . . VivoxService.Instance.LoggedIn += onLoggedIn; VivoxService.Instance.LoggedOut += onLoggedOut; . . . private void onLoggedIn() { // Operations as needed } private void onLoggedOut() { // Operations as needed }}