Sign in with the Authentication package
Prerequisite: Configure the Unity Package Manager Vivox package.
The easiest way to manage Vivox sign-ins is with the Unity Authentication package.
To use the Authentication package, complete the following steps.
Ensure that your project
manifest.json
file contains an entry forcom.unity.services.authentication
.For more information, refer to the Unity documentation on the Project manifest.
Initialize
UnityServices
by implementing the following code snippet into a script that runs before using any Vivox functionality.
using System;
using UnityEngine;
using Unity.Services.Authentication;
using Unity.Services.Core;
using Unity.Services.Vivox;
async void Start()
{
await UnityServices.InitializeAsync();
await AuthenticationService.Instance.SignInAnonymouslyAsync();
await VivoxService.Instance.InitializeAsync();
}
Log in by using
VivoxService.Instance.LoginAsync(LoginOptions options = null)
.Join a channel by using either of the following code examples depending on the type of channel.
When joining a non-positional channel use:
VivoxService.Instance.JoinGroupChannelAsync(
string channelName,
ChatCapability chatCapability,
ChannelOptions channelOptions = null
);
When joining a positional channel use:
VivoxService.Instance.JoinPositionalChannelAsync(
string channelName,
ChatCapability chatCapability,
Channel3DProperties positionalChannelProperties,
ChannelOptions channelOptions = null
);
When joining an echo channel use:
VivoxService.Instance.JoinEchoChannelAsync(
string channelName,
ChatCapability chatCapability,
ChannelOptions channelOptions = null
);