Updating player metadata

Update the signed-in player's metadata for your game.

The metadata of a player contains key statistics about the player (e.g. K/D ratio, level, XP) and are displayed publicly on the Sphere app. This helps other users get an overview of the player's progress in your game.

A maximum of 10 metadata fields are allowed, and values can only be strings (under 100 characters), numbers or booleans. Booleans will be displayed as "Yes" or "No" in the Sphere app.

You can update the player's metadata using the UpdatePlayerMetadata method in CoreServices. A dictionary with the field name as key and the operation as value must be provided as the parameter.

Supported operations

Operation name
Purpose
Example

Set

Sets the field to the specified value.

PlayerDataOperation.Set("Gold")

Inc

Increases the field by the specified value (or sets the field to the specified value if the field is not set).

PlayerDataOperation.Inc(10)

Dec

Decreases the field by the specified value (or sets the field to the specified value if the field is not set).

PlayerDataOperation.Dec(10)

Min

Sets the field to the specified value if it is lesser than the current value (or sets the field to the specified value if the field is not set).

PlayerDataOperation.Min(20)

Max

Sets the field to the specified value if it is greater than the current value (or sets the field to the specified value if the field is not set).

PlayerDataOperation.Max(5)

Mul

Multiplies the field by the specified value (or sets the field to 0 if the field is not set).

PlayerDataOperation.Mul(10)

Div

Divides the field by the specified value (or sets the field to 0 if the field is not set).

PlayerDataOperation.Div(3)

Unset

Deletes the field.

PlayerDataOperation.Unset()

Example

await CoreServices.UpdatePlayerMetadata(new Dictionary<string, PlayerDataOperation>
{
    { "K/D ratio", PlayerDataOperation.Set(1.5f) },
    { "Wins", PlayerDataOperation.Inc(1) },
    { "XP", PlayerDataOperation.Mul(2) }
});

Last updated