ドキュメント

​
​

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
    • 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

Synchronize player names in a session

Expose and read player display names as session player properties so all players can view each other's names.
読み終わるまでの所要時間 2 分
最終更新 6ヶ月前

When a player is authenticated through the Authentication service, you can write the player's name into the session as a player property, and update it during the session lifecycle.
You can achieve this functionality using the following two extension methods:
  • WithPlayerName(VisibilityPropertyOptions visibility)
    to enable synchronization on session creation and join.
  • GetPlayerName()
    to read the name from any session player.

Enable player name sync in session options

Use
WithPlayerName
to synchronize the player's authenticated name into the session with a chosen visibility. The following example demonstrates how to enable player-name synchronization on session creation:
var myPlayerName = "CustomName";await UnityServices.InitializeAsync();await AuthenticationService.Instance.SignInAnonymouslyAsync();await AuthenticationService.Instance.UpdatePlayerNameAsync(myPlayerName);// Configure your session and enable name sync (member visibility makes it readable by other members)var sessionOptions = new SessionOptions{ MaxPlayers = 4, Type = "Session"}.WithPlayerName(VisibilityPropertyOptions.Member);
注
Use
VisibilityPropertyOptions.Member
or
VisibilityPropertyOptions.Public
so other players can read the name. Use
VisibilityPropertyOptions.Private
if you don't want names to be visible to others. In that case, other players’
GetPlayerName()
calls return
null
.

Read player names from the session

Use
GetPlayerName
to retrieve the synchronized name from any player’s properties.
// Read your own player name (from the local session player)string myName = session.CurrentPlayer.GetPlayerName();// Read other players’ namesforeach (var player in session.Players){ var name = player.GetPlayerName() ?? $"Player {player.Id}"; UnityEngine.Debug.Log($"Player {player.Id} name: {name}");}
If a name isn’t available for any reason,
GetPlayerName()
returns
null
. For example, a name might be unavailable because the player hasn’t set a name, or the property isn't visible.
The player must be signed in and have a player name available via the Authentication service. Synchronization occurs while the session is connected. Updates made while disconnected won’t propagate until reconnected.

Additional resources

  • Authentication
  • Session operations as a host

Copyright © 2026 Unity Technologies
法規事項プライバシーポリシークッキーDocumentation Terms of Use私の個人情報を販売または共有しないプライバシーに関する選択 (クッキー設定)

"Unity" の名称、Unity のロゴ、およびその他の Unity の商標は、米国およびその他の国における Unity Technologies またはその関係会社の商標または登録商標です (詳しくはこちら)。その他の名称またはブランドは該当する所有者の商標です。

一部のページは利便性向上のため機械翻訳を使用しており、内容に不正確な表現が含まれる場合があります。内容に齟齬または不一致が生じた場合は、英語版を正本とします。

  • このページ
    • Enable player name sync in session options

    • Read player names from the session

    • Additional resources


このページの問題を報告する