メインコンテンツまでスキップ

ゲームで複数のレジストリのサポートを有効にする (Unity)

Last updated on December 17, 2024

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 and AccelByteSDK.GetServerRegistry.

For the best API access experience, we recommend using AGS SDK.

NOTES
  • The AccelByteSDK.GetClientRegistry and AccelByteSDK.GetServerRegistry APIs are available in the AGS SDK starting from v16.14.0.
  • The following APIs are now deprecated:
    • AccelBytePlugin/AccelByteServerPlugin
    • MultiRegistry

Game client

  1. Use Find all to locate all the AccelByte.Api.AccelBytePlugin. instances and replace them with AccelByte.Core.AccelByteSDK.GetClientRegistry().GetApi().

  2. Use Find all to locate all the AccelBytePlugin. instances and replace them with AccelByte.Core.AccelByteSDK.GetClientRegistry().GetApi().

  3. If you have multiple local players in the same game instance, update AccelByteSDK.GetClientRegistry().GetApi() with AccelByteSDK.GetClientRegistry().GetApi("INSERT_PLAYER_IDENTIFIER_HERE").

  4. Verify that the compilation still runs after the changes.

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
});

Game server

  1. Use Find all to locate all the AccelByte.Server.AccelByteServerPlugin. instances and replace them with AccelByte.Core.AccelByteSDK.GetServerRegistry().GetApi().

  2. Use Find all to locate all the AccelByteServerPlugin. instances and replace them with AccelByte.Core.AccelByteSDK.GetServerRegistry().GetApi().

  3. Verify that the compilation still runs after the changes.

AccelByteSDK.GetServerRegistry().GetApi().GetDedicatedServer().LoginWithClientCredentials(
result =>
{
if (result.IsError)
{
// Handle login error
Debug.Log($"Login Failed: {result.Error.Message}");
return;
}

// Handle login success
});