文档

​
​

Development

User Acquisition

Monetization

工业

Multiplayer Services SDK

All Services

Multiplayer Services SDK

此页面不支持所选语言。
Multiplayer
​
​
Multiplayer Services SDK
  • Overview
  • Get started
  • Use multiplayer sessions
    • Integrate Multiplayer sessions
    • Game server hosting support
  • Manage sessions
  • Connect players through a relay
  • Networking
  • Matchmaking
  • Monitor and debug sessions
  • Tutorials
  • Reference
  1. Multiplayer Services SDK

Game server hosting support

Integrate different hosting solutions using Cloud Code modules to manage servers.
阅读时间2 分钟
最后更新于 3 天前

Multiplayer Services are compatible with many game server hosting providers to provide advanced multiplayer features. In combination with Cloud Code modules, you can allocate servers, create multiplayer sessions, and enable player backfilling.

Hosting with Cloud code modules

The matchmaker services within the Multiplayer Services SDK can use Cloud Code modules to allocate game servers and coordinate matchmaking results.
Refer to the documentation on Hosting with Cloud Code modules for further details.

Authentication

You must authenticate the server with a service account using
ServerAuthenticationService.Instance.SignInWithServiceAccountAsync
. Refer to Create a service account.

Backfilling

If Matchmaker allocated the server, it's possible to automatically request new players to join to backfill empty slots. These empty slots could be due to players leaving the session or because Matchmaker quickly created the match to minimize matchmaking time:
// Adapt session options to your game needs var sessionOptions = new SessionOptions(){ MaxPlayers = 2};// Add backfilling configuration if you want the session to automatically set up backfill when a player leaves.// This requires having the "Matchmaker Backfill Admin" permission on your service account.sessionOptions.WithBackfillingConfiguration( enable: true, automaticallyRemovePlayers: true, autoStart: true, playerConnectionTimeout: 30, backfillingLoopInterval: 1);
This code can start the backfilling process as soon as the session is created. Additionally, this code automatically starts the backfilling process when the session has one more empty slot.
Backfilling requires having the "Matchmaker Backfill Admin" permission on your service account. Refer to Matchmaker Backfill Admin for the required Matchmaker backfill API permission.
注意
MaxPlayers
in the session options must be equal to or higher than the maximum players set in the matchmaking configuration.
It's also possible to manually start and stop the backfilling process using the following code:
IServerSession session = await MultiplayerServerService.Instance.CreateMatchSessionAsync(matchId, sessionOptions);// Start the backfilling if it is not already in progressawait session.StartBackfillingAsync();/// Stop the backfillingawait session.StopBackfillingAsync();
Starting and stopping the backfilling of a session can be useful if certain times aren't appropriate for players to be joining (for example, if the session is about to end, or if a cinematic is in progress).
Refer to WithBackfillingConfiguration() for more information on the backfilling configuration.

Additional resources

  • WithBackfillingConfiguration()
  • Backfill (Matchmaker)
  • Matchmaker Backfill Admin

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • Hosting with Cloud code modules

    • Authentication

    • Backfilling

    • Additional resources


报告此页面的问题