Migrate to the Multiplayer Services SDK
Transfer from the individual services' SDKs to the unified Multiplayer Services SDK.
読み終わるまでの所要時間 3 分最終更新 16時間前
The Multiplayer Services SDK unites the functionality of the standalone SDKs from the following services:
- Lobby
- Matchmaker
- Relay
If you're already using any of the SDKs from these individual services in your project but want to move to the unified Multiplayer Services SDK, you must first migrate from the individual services' packages to the Multiplayer Services package.
Differences between the Sessions API and the direct services API
The following table compares the high level view for peer-to-peer matchmaking when using Matchmaker, Lobby, and Relay individually versus using the Sessions API. This comparison highlights the reduced amount of steps needed to execute workflows between the APIs.
Direct services APIs | Sessions API equivalent | |
|---|---|---|
| Host | 1. Create a Matchmaker ticket 2. Wait for the ticket to find a match 3. Create a lobby 4. Continuously heartbeat the Lobby 5. Create a Relay allocation 6. Add the Relay allocation ID to the Lobby host player 7. Start the NetworkManager | 1. Start Matchmaking with Relay |
| Joining player | 1. Create a Matchmaker ticket 2. Wait for the ticket to find a match 3. Join the lobby based on the match ID 4. Join the Relay allocation 5. Add the Relay allocation ID to the Lobby player 6. Start NetworkManager | 1. Start Matchmaking |
Migrate from Lobby
To migrate from the Lobby SDK to the unified Multiplayer Services SDK, do the following:
- Remove the Lobby package from the Package Manager.
- Install the Multiplayer Services package from the Package Manager.
- Change any usage of to
Lobbies.InstanceLobbyService.Instance
You have now migrated the functionality of the Lobby SDK to the Multiplayer Services SDK in your project.
Migrate from Matchmaker
To migrate from the Matchmaker SDK to the unified Multiplayer Services SDK, do the following:
- Remove the Matchmaker package from the Package Manager.
- Install the Multiplayer Services package from the Package Manager.
You have now migrated the functionality of the Matchmaker SDK to the Multiplayer Services SDK in your project.
Migrate from Relay
To migrate from the Relay SDK to the unified Multiplayer Services SDK, do the following:
- Remove the Relay package from the Package Manager.
- Install the Multiplayer Services package from the Package Manager.
- Change any usage of to
Relay.Instance.RelayService.Instance - Change constructors into
RelayServerData(hostAllocation, connectionType). Refer to the code below for more details.AllocationUtils.ToRelayServerData(hostAllocation, connectionType)
If you use Relay with the Unity Transport Protocol (UTP), adapt the creation of the using the following sample code:
RelayServerDataFor the host
// maxConnections is the maximum number of connections the allocation is expecting// connectionType is the host connection type, this can be "dtls", "udp" or "wss"// create allocationvar allocation = await RelayService.Instance.CreateAllocationAsync(maxConnections);var relayServerData = allocation.ToRelayServerData(connectionType);NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(relayServerData);
For the joining player
// connectionType is the host connection type, this can be "dtls", "udp" or "wss"// joinCode is the allocation join code shared by the host player after creating the allocation and retrieving the join codevar allocation = await RelayService.Instance.JoinAllocationAsync(joinCode);var relayServerData = allocation.ToRelayServerData(connectionType);NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(relayServerData);
Refer to Use Relay with Netcode for GameObjects for more details on using Relay with Netcode for GameObjects with the Multiplayer Services SDK.