Stats are a convenient way of tracking player information such as game wins, losses, kills, deaths, etc. Many platforms have a feature to display a player’s stats.
Stats are automatically saved to a file, named PLAYERSTATS, then asyncrously set on your platform’s backend. We do this to ensure a single development workflow where savings stats to PLAYERSTATS file is a reliable method of tracking stats for any platform. This also allows the developer to setup stats on platform backends in hindsight.
Set a stat value
...
public static void SetStat(PlatformPlayer player, Stat stat, float value)
{
player.SetStat(stat, value,
(value, result) =>
{
if(result == PlatformPlayer.StatResult.Success)
{
Debug.Log("Stat successfully set!");
}
},
(value, result) =>
{
if(result == PlatformPlayer.StatResult.Success)
{
Debug.Log("Platform stat set successfully!");
}
}
);
}
...
ex: Stat scriptable object for ‘Games Won’