Important: This is documentation for the legacy version of the Vivox Unity SDK. This documentation will be removed after July 2025. Refer to the v16 documentation for the new version of the SDK.
Uninitialize the Vivox SDK
The game must uninitialize the Vivox SDK by calling Client.Uninitialize()
before exiting the process or before calling Client.Initialize()
again. If this operation is called while a user is signed in, the method can block for up to two seconds while it cleans up network resources.
Uninitialization handles the sign out process, so it is not necessary have a user individually leave channels and then sign out. Uninitialization is a safe way to unwind all Vivox resources.
The following code displays an example of the uninitialization process:
using UnityEngine;
using VivoxUnity;
class UninitializeExample : MonoBehaviour
{
. . .
// For this example, _client is assumed to be an initialized Client.
void UninitializeClient()
{
. . .
_client.Uninitialize();
. . .
}
. . .
}
When testing using the Unity Play mode in the Unity Editor, you might need to ensure that Client.Uninitialize()
is called before Client.Initialize()
to avoid getting a 5041: VxErrorAlreadyInitialized
error. This is caused by the Unity Editor not fully resetting the Vivox SDK and would not be seen in a built application that has restarted. If you are encountering this error, you can call Client.Uninitialize()
inside of the OnApplicationQuit()
function. This ensures that Client.Uninitialize()
is called when you exit Play mode and enter Edit mode within the Unity Editor.
Important: If you have encountered this error, you have to close and reopen your Unity project before the fix can take effect.
The following example displays an example of this process:
using UnityEngine;
using VivoxUnity;
class ApplicationQuitExample : MonoBehaviour
{
. . .
void OnApplicationQuit()
{
_client.Uninitialize();
}
. . .
}