Sign in to a game
How to sign in a player to Vivox services.
Read time 2 minutesLast updated 2 days ago
After you initialize the Vivox SDK, you can sign a user in to the Vivox instance assigned to your game. The name being used for players will either be the Unity AuthenticationId, or a new GUID, if Unity Authentication is not being used.
After initialization, call the
VivoxService.Instance.LoginAsync- The optional argument of is a LoginOptions struct that can set a display name for the user, enable Text-to-Speech, or load in a blocked user list.
VivoxService.Instance.LoginAsync
VivoxService.Instance.ParticipantAddedToChannelVivoxService.Instance.ParticipantRemovedFromChannel- The display name is only valid for the current session and does not persist in the Vivox network.
- The maximum display name length is 127 bytes.
The following code is an example of how to initiate the sign-in process, setting the DisplayName to "Bob", and enabling Text-to-Speech.
You can subscribe tousing 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) } . . .}
VivoxService.Instance.LoggedInVivoxService.Instance.LoggedOutVivoxService.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 }}