Initialize the voice client object
You must create and initialize the voice client before other Vivox SDK actions can take place. During the voice client initialization process, the Vivox SDK sets up and starts all of its different subsystems. This can cause additional shared libraries to be loaded, and allows developers to customize a variety of Vivox SDK options before connecting to Vivox services. For example, a developer can select between available codecs, audio ducking settings, and logging level.
await VivoxService.Instance.InitializeAsync(VivoxConfigurationOptions config)
has optional parameters that you can use to choose the configuration of the Vivox Core SDK.
The following code displays an example of how to create and initialize the voice client on Windows, macOS, Android, and iOS:
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();
}
Important: If the client is already initialized and the application attempts to initialize the client again, it encounters a 5041:VxErrorAlreadyInitialized
error. For information on this error refer to the Vivox SDK error codes.
For more details on the Unity Authentication Service, refer to Sign-in with the Authenticaiton package. For alternative authentication approaches, refer to Sign-in with Custom IDs, or if you are already using Vivox Access Tokens in your application, refer to Using VATs with UAS.