docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class UpdatePlayerOptions

    PlayerDataObject to update on a given player update request.

    Used in conjunction with UpdatePlayerAsync(string, string, UpdatePlayerOptions).

    Inheritance
    object
    UpdatePlayerOptions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Services.Lobbies
    Assembly: Unity.Services.Multiplayer.dll
    Syntax
    public class UpdatePlayerOptions

    Properties

    AllocationId

    An ID that associates this player in this lobby with a persistent connection. When a disconnect notification is received, this value is used to identify the associated player in a lobby to mark them as disconnected.

    Declaration
    public string AllocationId { get; set; }
    Property Value
    Type Description
    string

    ConnectionInfo

    Connection information for connecting to a relay with this player.

    Declaration
    public string ConnectionInfo { get; set; }
    Property Value
    Type Description
    string

    Data

    Custom game-specific properties to add, update or remove from the player (for example, role or skill).

    Declaration
    public Dictionary<string, PlayerDataObject> Data { get; set; }
    Property Value
    Type Description
    Dictionary<string, PlayerDataObject>
    Remarks

    To remove an existing player data, include it in Data but set property object to null.
    To update the value to null, set the Value of the player data object to null.

    Examples

    To add a colour player data

    var redColourPlayerData = new PlayerDataObject(VisibilityOptions.Public, "red")
        var data = new Dictionary<string, PlayerDataObject> { ["colour"] = redColourPlayerData };
        LobbyService.Instance.UpdatePlayerAsync("lobbyId", "playerId", data);

    To update the colour player data to null

    var nullPlayerDataObject = new PlayerDataObject(VisibilityOptions.Public, null)
        var data = new Dictionary<string, PlayerDataObject> { ["colour"] = nullPlayerDataObject };
        LobbyService.Instance.UpdatePlayerAsync("lobbyId", "playerId", data);

    To remove the colour player data

    var data = new Dictionary<string, PlayerDataObject> { ["colour"] = null };
        LobbyService.Instance.UpdatePlayerAsync("lobbyId", "playerId", data);
    See Also
    PlayerDataObject(VisibilityOptions, string)
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)