ゲームにサインインする
How to sign in a player to Vivox services.
読み終わるまでの所要時間 1 分最終更新 7ヶ月前
Vivox SDK を初期化した後は、そのゲームに割り当てられた Vivox インスタンスにユーザーをサインインさせることができます。
プレイヤーに使用される名前は、Unity AuthenticationId か、Unity Authentication が使用されていない場合は新しい GUID になります。
初期化されたら、 メソッドを呼び出して Vivox にサインインします。
VivoxService.Instance.LoginAsync- のオプションの引数は LoginOptions 構造体で、ユーザーの表示名を設定する、テキスト音声変換を有効にする、またはブロックユーザーリストをロードすることができます。
VivoxService.Instance.LoginAsync
LoginOptions で表示名が設定されると、この名前は参加するチャンネル内のすべてのユーザーに表示されます。ユーザーはこれを DisplayName (VivoxParticipant の結果内) として、 または から受け取ります。
VivoxService.Instance.ParticipantAddedToChannelVivoxService.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.LoggedInVivoxService.Instance.LoggedOut以下のコードは、 イベントと イベントにサブスクライブする方法と、LoginState の値が異なる関数を処理する方法の例です。
VivoxService.Instance.LoggedInVivoxService.Instance.LoggedOutusing 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 }}