Enable multiple registries support in your game (Unity)
Overview
The AccelByte Gaming Services (AGS) Multiple Registries feature supports multiplayer in a single game process.
This article walks you through how to:
- Migrate your Unity game from a singleton-based registry to multiple registries, enabling it to support multiple registries.
- Transition to the latest
AccelByteSDK.GetClientRegistry
andAccelByteSDK.GetServerRegistry
.
For the best API access experience, we recommend using AGS SDK.
- The
AccelByteSDK.GetClientRegistry
andAccelByteSDK.GetServerRegistry
APIs are available in the AGS SDK starting from v16.14.0. - The following APIs are now deprecated:
AccelBytePlugin/AccelByteServerPlugin
MultiRegistry
Game client
- From AccelBytePlugin
- From MultiRegistry
Use Find all to locate all the
AccelByte.Api.AccelBytePlugin.
instances and replace them withAccelByte.Core.AccelByteSDK.GetClientRegistry().GetApi().
Use Find all to locate all the
AccelBytePlugin.
instances and replace them withAccelByte.Core.AccelByteSDK.GetClientRegistry().GetApi().
If you have multiple local players in the same game instance, update
AccelByteSDK.GetClientRegistry().GetApi()
withAccelByteSDK.GetClientRegistry().GetApi("INSERT_PLAYER_IDENTIFIER_HERE")
.Verify that the compilation still runs after the changes.
- Latest Usage
- Previous Usage
User user = AccelByteSDK.GetClientRegistry().GetApi().GetUser();
user.LoginWithUsernameV3(
"user+a@example.com",
"Password321",
(Result<TokenData, OAuthError> result) =>
{
if (result.IsError)
{
// Handle login error
Debug.Log($"Login Failed: {result.Error.error_description}");
return;
}
// Handle login success
});
User user = AccelBytePlugin.GetUser();
user.LoginWithUsernameV3(
"user+a@example.com",
"Password321",
(Result<TokenData, OAuthError> result) =>
{
if (result.IsError)
{
// Handle login error
Debug.Log($"Login Failed: {result.Error.error_description}");
return;
}
// Handle login success
});
Use Find all to locate all the
MultiRegistry.GetApiClient
instance and replace them withAccelByteSDK.GetClientRegistry().GetApi
Verify that the compilation still runs after the changes.
- Latest Usage
- Previous Usage
User user = AccelByteSDK.GetClientRegistry().GetApi("Player1").GetUser();
user.LoginWithUsernameV3(
"user+a@example.com",
"Password321",
(Result<TokenData, OAuthError> result) =>
{
if (result.IsError)
{
// Handle login error
Debug.Log($"Login Failed: {result.Error.error_description}");
return;
}
// Handle login success
});
User user = MultiRegistry.GetApiClient("Player1").GetUser();
user.LoginWithUsernameV3(
"user+a@example.com",
"Password321",
(Result<TokenData, OAuthError> result) =>
{
if (result.IsError)
{
// Handle login error
Debug.Log($"Login Failed: {result.Error.error_description}");
return;
}
// Handle login success
});
Game server
- From AccelByteServerPlugin
- From MultiRegistry
Use Find all to locate all the
AccelByte.Server.AccelByteServerPlugin.
instances and replace them withAccelByte.Core.AccelByteSDK.GetServerRegistry().GetApi().
Use Find all to locate all the
AccelByteServerPlugin.
instances and replace them withAccelByte.Core.AccelByteSDK.GetServerRegistry().GetApi().
Verify that the compilation still runs after the changes.
- Latest Usage
- Previous Usage
AccelByteSDK.GetServerRegistry().GetApi().GetDedicatedServer().LoginWithClientCredentials(
result =>
{
if (result.IsError)
{
// Handle login error
Debug.Log($"Login Failed: {result.Error.Message}");
return;
}
// Handle login success
});
AccelByteServerPlugin.GetDedicatedServer().LoginWithClientCredentials(
result =>
{
if (result.IsError)
{
// Handle login error
Debug.Log($"Login Failed: {result.Error.Message}");
return;
}
// Handle login success
});
Use Find all to locate all the
MultiRegistry.GetServerApiClient
instances and replace them withAccelByteSDK.GetServerRegistry().GetApi
Verify that the compilation still runs after the changes.
- Latest Usage
- Previous Usage
AccelByteSDK.GetServerRegistry().GetApi().GetDedicatedServer().LoginWithClientCredentials(
result =>
{
if (result.IsError)
{
// Handle login error
Debug.Log($"Login Failed: {result.Error.Message}");
return;
}
// Handle login success
});
MultiRegistry.GetServerApiClient().GetDedicatedServer().LoginWithClientCredentials(
result =>
{
if (result.IsError)
{
// Handle login error
Debug.Log($"Login Failed: {result.Error.Message}");
return;
}
// Handle login success
});