기술 자료

Development

User Acquisition

Monetization

산업 분야

Multiplayer Services SDK

All Services

Multiplayer Services SDK

이 페이지는 선택한 언어로 제공되지 않습니다.
Multiplayer
​
​
Multiplayer Services SDK
  • Overview
  • Get started
  • Use multiplayer sessions
  • Manage sessions
    • Lobby events
    • Rate limits
    • Information management in sessions
      • Session data and player data
      • Update session data
      • Update player data
      • Manage properties as a host
      • Manage properties as a client
    • Synchronize player names in a session
    • Access control
    • Session error messages
  • Connect players through a relay
  • Networking
  • Matchmaking
  • Monitor and debug sessions
  • Tutorials
  • Reference
  1. Multiplayer Services SDK

Manage properties as a host

Manage your sessions with the operations available to you as a session host.
읽는 시간 3분
최근 업데이트: 4달 전

As a session host, you have access to operations that let you interact with session and player properties.
Note that some host operations differ from those available to clients.

Session property operations

The host can read, add, update, or remove properties from a session.

Read APIs

The following APIs allow the host to read session properties:
IReadOnlyDictionary<string, SessionProperty> ISession.Properties { get; }

Read a session property

The following code snippet demonstrates how to read the
colour
property:
if (clientSession.Properties.TryGetValue("colour", out var colour)){ Debug.Log($"The colour session property is {colour.Value}");}

Write APIs

The following APIs allow the host to modify session properties:
void IHostSession.SetProperties(Dictionary<string, SessionProperty> properties);void IHostSession.SetProperty(string key, SessionProperty property);Task IHostSession.SavePropertiesAsync();

Add a session property

To add a property to a session, you must decide upon the visibility of the property:
  • Public (visible to everyone and is included in query result)
  • Member (visible to members of the session)
  • Private (visible to the member who set it)
After you decide the required visibility, you must create the session property, set it, and save it to the session. The following code snippet demonstrates how to add a
colour
property with the value
red
in
hostSession
:
var redColourProperty = new SessionProperty("red", VisibilityOptions.Public);hostSession.SetProperty("colour", redColourProperty);await hostSession.SavePropertiesAsync();

Update a session property

The following code snippet demonstrates how to set the
colour
property to
null
in
hostSession
.
var nullSessionProperty = new SessionProperty(null, VisibilityOptions.Public);hostSession.SetProperty("colour", nullSessionProperty);await hostSession.SavePropertiesAsync();

Delete a session property

The following code snippet demonstrates how to delete the
colour
property in
hostSession
.
hostSession.SetProperty("colour", null);await hostSession.SavePropertiesAsync();

Player property operations

The host can read, add, update, or remove properties from any player.

Read APIs

The following APIs allow the host to read player properties:
IReadOnlyList<IPlayer> IHostSession.Players { get; }IReadOnlyDictionary<string, PlayerProperty> IReadOnlyPlayer.Properties { get; }

Read a player property

The following code snippet demonstrates how to read the
colour
player property.
if (hostSession.Players.First().Properties.TryGetValue("colour", out var colour)){ Debug.Log($"First player colour property is {colour.Value}");}

Write APIs

The following APIs allow the host to modify player properties:
IReadOnlyList<IPlayer> IHostSession.Players { get; }Task IHostSession.SavePlayerDataAsync(string playerId);void IPlayer.SetProperty(string key, PlayerProperty property);void IPlayer.SetProperties(Dictionary<string, PlayerProperty> properties);

Add a player property

To add a property to a player, you must decide upon the visibility of the property:
  • Public (visible to everyone)
  • Member (visible to members of the session)
  • Private (visible to the player who owns the property and the host)
The following code snippet demonstrates how to add a
colour
property with the value
red
in
firstPlayer
, which is the first client in the list of clients:
var firstPlayer = hostSession.Players.First()var redColourProperty = new PlayerProperty("red");firstPlayer.SetProperty("colour", redColourProperty);await hostSession.SavePlayerDataAsync(firstPlayer.Id);

Update a player property

The following code snippet demonstrates how to set the
colour
property to
null
in
firstPlayer
:
var firstPlayer = hostSession.Players.First()var nullColourProperty = new PlayerProperty(null);firstPlayer.SetProperty("colour", nullColourProperty);await hostSession.SavePlayerDataAsync(firstPlayer.Id);

Delete a player property

The following code snippet demonstrates how to delete the
colour
property in
firstPlayer
:
var firstPlayer = hostSession.Players.First()firstPlayer.SetProperty("colour", null);await hostSession.SavePlayerDataAsync(firstPlayer.Id);

Elect a new session host

The following code snippet demonstrates how to elect a given
player
by its ID as the new host:
public Task ElectPlayerAsHostAsync(string playerId){ _session.AsHost().Host = player.Id; return _session.AsHost().SavePropertiesAsync();}
After setting the
session
's host ID, save the changes to take effect.
참고
The host election process doesn't handle the data migration of the network session, it only chooses a new session host. For the network data migration, refer to Session migration.

Copyright © 2026 Unity Technologies
법률 정보개인정보 처리방침쿠키Documentation Terms of Use개인 정보 판매 또는 공유 금지개인정보 보호 선택(쿠키 설정)

'Unity', Unity 로고 및 기타 Unity 상표는 미국 및 기타 지역 내 Unity Technologies 또는 그 계열사의 상표 또는 등록상표입니다(자세한 내용은 여기에서 확인하세요). 기타 명칭 또는 브랜드는 해당 소유자의 상표입니다.

일부 페이지는 편의를 위해 기계 번역되었으며 부정확한 내용이 있을 수 있습니다. 정보가 상충되는 경우, 영어 버전을 우선으로 참조하세요.

  • 보고 있는 페이지
    • Session property operations

      • Read APIs

      • Read a session property

      • Write APIs

      • Add a session property

      • Update a session property

      • Delete a session property

    • Player property operations

      • Read APIs

      • Read a player property

      • Write APIs

      • Add a player property

      • Update a player property

      • Delete a player property

      • Elect a new session host


이 페이지의 문제 보고
​
​