v1.1.4
Latest
2022.3+
Interface IPlayer
An interface that allows to modify the properties of a Player.
Inherited Members
Namespace: Unity.Services.Multiplayer
Syntax
public interface IPlayer : IReadOnlyPlayer
Methods
SetAllocationId(String)
Set the allocationId
returned by the networking solution which associates this player in this session with a persistent connection.
Declaration
void SetAllocationId(string allocationId)
Parameters
Type | Name | Description |
---|---|---|
System.String | allocationId | This value is used to identify the associated member in a session. |
SetProperties(Dictionary<String, PlayerProperty>)
Modifies multiple PlayerProperty of the player.
Declaration
void SetProperties(Dictionary<string, PlayerProperty> properties)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, PlayerProperty> | properties | A dictionary of PlayerProperty to be added, updated or removed. |
See Also
SetProperty(String, PlayerProperty)
Modifies a single PlayerProperty of the IPlayer.
Declaration
void SetProperty(string key, PlayerProperty property)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The PlayerProperty's key. |
PlayerProperty | property | The PlayerProperty's value. |
Remarks
To set the value of the property to null, pass a PlayerProperty with its Value set to null.
To remove an existing property, pass null to the property
argument.
Examples
To add a colour
property
var player = mySession.CurrentPlayer;
var redColourProperty = new PlayerProperty("red");
player.SetProperty("colour", redColourProperty);
await mySession.SaveCurrentPlayerDataAsync();
To update the colour
property to null
var player = mySession.CurrentPlayer;
var nullColourProperty = new PlayerProperty(null);
player.SetProperty("colour", nullColourProperty);
await mySession.SaveCurrentPlayerDataAsync();
To remove the colour
property
var player = mySession.CurrentPlayer;
player.SetProperty("colour", null);
await mySession.SaveCurrentPlayerDataAsync();