Unit Stats Provider
Scripting with the UnitStatsProvider class.
The UnitStatsProvider class is used to provide stats to GameObjects. It will be necessary to manage the stats through code at runtime. In the examples below, unitStatsProvider is an instance of a UnitStatsProvider.
Getting Stats
You can get a stat by its name or abbreviation.
Stat myStat = unitStatsProvider.GetStat("My Stat Name");Alternatively, you can access all stats with data.stats.
var myStatList = unitStatsProvider.data.stats;Updating Stats
Stat values can be set with the SetStat method.
// Parameters: stat name, new stat value
unitStatsProvider.SetStat("My Stat Name", 100);You can increase a stat by a certain amount with the IncreaseStat method.
// Parameters: stat name, added stat value
unitStatsProvider.IncreaseStat("My Stat Name", 100);A stat's value can be decreased with the DecreaseStat method.
// Parameters: stat name, removed stat value
unitStatsProvider.DecreaseStat("My Stat Name", 100);To reset all stats, call the ResetAllStats method.
unitStatsProvider.ResetAllStats();Leveling
When the level of a UnitStatsProvider is changed, all of its stats level's will be adjusted to match.
SetLevel
Set the level with the SetLevel method.
// Set the level to 1
unitStatsProvider.SetLevel(1);LevelUp
Call LevelUp to increase the level by 1.
unitStatsProvider.LevelUp();LevelDown
Use LevelDown to have the opposite effect.
unitStatsProvider.LevelDown();Last updated