文档

​
​

Development

User Acquisition

Monetization

工业

Multiplayer Services SDK

All Services

Multiplayer Services SDK

此页面不支持所选语言。
Multiplayer
​
​
Multiplayer Services SDK
  • Overview
  • Get started
  • Use multiplayer sessions
  • Manage sessions
  • Connect players through a relay
  • Networking
  • Matchmaking
  • Monitor and debug sessions
  • Tutorials
  • Reference
    • Privacy and consent
    • Support
    • Glossary
    • Frequently asked questions
    • Multiplayer Services Building Blocks
    • Reference
  1. Multiplayer Services SDK

Frequently asked questions

Common questions concerning the Multiplayer Services SDK.
阅读时间3 分钟
最后更新于 16 天前

What is the purpose of sessions, and how do they relate to the individual services?

The Unity Multiplayer SDK uses Sessions as a comprehensive wrapper to simplify the integration of Unity Gaming Services (UGS) backend features, such as Lobby, Relay, and Matchmaker into multiplayer games. This single interface reduces boilerplate code and standardizes UGS usage, automatically managing features like Lobby heartbeating and, when enabled, the Lobby/Relay integration, allowing developers to focus on unique game features.

How does the Sessions API compare to the direct services API?

The following table compares the high level view for P2P Matchmaking when using Matchmaker, Lobby, and Relay individually versus using the Sessions API.

Direct services APIs

Sessions API equivalent

Host1. 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 player1. 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

Which APIs are deprecated?

The following standalone SDKs are depreacted:
  • Lobby:
    com.unity.services.lobby
  • Relay:
    com.unity.services.relay
  • Matchmaker:
    com.unity.services.matchmaker
The standalone SDKs are deprecated in favor of
com.unity.services.multiplayer
, their functionalities are still accessible within
com.unity.services.multiplayer
. Upgrade to the Multiplayer Services SDK by following the migration guide.

How does the session interact with the network?

Starting with version
1.2.0-pre.1
of
com.unity.services.multiplayer
, you can now choose when to start the network connection in your game flow. This isn't available with Matchmaking.
If you make the host use
WithRelayNetwork
,
WithDirectNetwork
or
WithDistributedAuthorityNetwork
when creating the session, then the network starts automatically as soon as the session is created. Any player joining this same session is pulled into the network connection automatically.
If you don't make the host use
WithRelayNetwork
,
WithDirectNetwork
or
WithDistributedAuthorityNetwork
when creating the session, then no network connection is automatically established. You can then execute any pre-match setup such as choosing a character or waiting for all players to be ready before establishing the network connection. No network is created for any player joining this session at that point. When the host is ready, they can use
StartRelayNetwork
,
StartDirectNetwork
or
StartDistributedAuthorityNetwork
to start the network. Any player joining this session after the network start is pulled into the network connection automatically.

Are there WebGL limitations?

The Multiplayer SDK supports the WebGL target, however, User Datagram Protocol isn't supported for this platform, consequently, Quality of service isn't available, neither is the Datagram Transport Layer Security encryption protocol for Relay. Broader limitations remain, even those unrelated to the Multiplayer SDK, such as restrictions on multithreading including the use of
Task.Delay
.

How is the Sessions API priced?

The Session API wraps multiple services into a single SDK. This includes Relay, Distributed Authority, Lobby, and Matchmaker and therefore contributes to the billing of each of those services.
Refer to the Unity Gaming Services pricing page for complete details.

How do you enable verbose logging?

Set the
ENABLE_UNITY_MULTIPLAYER_VERBOSE_LOGGING
scriptable define under Script Compilation in the Player window of the Untiy Editor.

Would it be possible to matchmake to a session based on the best latency?

Quality of service (QoS) measurements are automatically used in the Sessions API when a player calls
MatchmakeSessionAsync
.

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

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

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

  • 在本页上
    • What is the purpose of sessions, and how do they relate to the individual services?

    • How does the Sessions API compare to the direct services API?

    • Which APIs are deprecated?

    • How does the session interact with the network?

    • Are there WebGL limitations?

    • How is the Sessions API priced?

    • How do you enable verbose logging?

    • Would it be possible to matchmake to a session based on the best latency?


报告此页面的问题