Learn how Multiplayer Widgets work on the client and host
Some Multiplayer Widgets exist only on a client, some only exist on a host, and some can automatically switch between the client and the host. This can happen when the Player enters or leaves an active session and when the Player becomes a host or a client.
When you enter Play mode, each Multiplayer Widget is inactive for a moment until Unity initializes the Unity Gaming Services (UGS) that each Multiplayer Widget uses. To manually override automatic initialization, refer to Control how Unity initializes a multiplayer service.
To test multiple Players on the client and host, use Multiplayer Play Mode.
Note: To learn which sessions currently exist for your project, go to Services > Multiplayer > Sessions Viewer.
Determine the client or host status of a Multiplayer Widget
The state of each widget automatically changes in response to changes in a session.
The active Multiplayer Widgets in each Player determine the client or host status of that Player. The Player that creates the session becomes the host.
A Player that joins an active session becomes a client.
To use any Multiplayer Widget, enter Play mode. When a Multiplayer Widget is inactive, its UI element is disabled.
Note: If no Multiplayer Widgets are active, you might need to link your project on the cloud.
Widget | Player status | Active state | Inactive state |
---|---|---|---|
Create Session | Host | The Create Session button is active when the Player isn't in a session and the Session Name field contains any value. | The Player enters a session or when the Session Name field is empty. |
Join Session By Code | Client | The Player isn’t in a session and a session code is entered. | The Player is in a session. |
Session List | Client | A session is selected and the Player isn’t in a session. | The Player is in a session. |
Quick Join Session | Host and client | The Player isn't in a session. | The Player has joined a session. |
Leave Session | Host and client | The Player has joined a session. | The Player isn't in a session. |
Session Player List | Host and client | Generates a list of players when each player enters or leaves the session. | Never. |
Show Session Code | Host and client | Displays the session code when the Player is in a session. | The Player isn’t in a session. |
Select Input Audio Device | Host and client | Always active. | Never. |
Select Output Audio Device | Host and client | Always active. | Never. |
Text Chat | Host and client | The Player has joined a Chat session. | The Player isn’t in a Chat session. |