Interface IPlayer
An interface that allows to modify the properties of a Player.
Inherited Members
Namespace: Unity.Services.Multiplayer
Assembly: Unity.Services.Multiplayer.dll
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 |
|---|---|---|
| string | allocationId | This value is used to identify the associated member in a session. |
SetProperties(Dictionary<string, PlayerProperty>)
Modifies multiple properties of the player.
Declaration
void SetProperties(Dictionary<string, PlayerProperty> properties)
Parameters
| Type | Name | Description |
|---|---|---|
| Dictionary<string, PlayerProperty> | properties | A dictionary of player properties to be added, updated or removed. |
See Also
SetProperty(string, PlayerProperty)
Modifies a single PlayerProperty of the player.
Declaration
void SetProperty(string key, PlayerProperty property)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The player property's key. |
| PlayerProperty | property | The player property'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();