Skill Tree
  • Skill Tree Documentation
  • Legacy Product
  • đŸ•šī¸Quick Start
    • Installation
    • Default Prefabs
    • Start Editing
    • Making it Work
  • 🎮Demo Scene
    • Endless Death
  • âš™ī¸Systems
    • Skill Tree
      • Editor Window
        • Skill Trees (Skill Graphs)
        • Skills (Skill Nodes)
          • Skill Stats Editor
          • Text Tags
        • Connections
      • Skill Tree Settings
      • Components
        • Skill Tree Initializer
        • Default Components
          • Confirmation Prompt
          • Default Input Handler
          • Skill Tree Window
          • Skill Details
          • Skill Menu
          • Skill Bar & Windup UI
        • Skill Interpreter
      • Customizations
        • UI Customizations
          • Custom Skill Menu
          • Custom Skill Details
        • Custom Objects
      • Scripting
        • Initialization
        • Player Level & Skill Points
        • Skill Graphs
        • Skill Nodes
        • Using Skills
        • Saving & Loading Graphs
        • Default Skill Tree Window
        • Events
    • Stats
      • Stats Editor
      • Components
        • Unit Stats Provider
      • Creating & Providing Stats
      • Scripting
        • Stat Groups & Identities
        • Stats
        • Unit Stats Provider
          • Events
        • Saving & Loading Stats
  • đŸ› ī¸Support
    • Getting Help
  • 📚Changelogs
    • Latest Releases
  • ⭐Rate Me?
Powered by GitBook
On this page
  • Getting Stats
  • Updating Stats
  • Leveling
  • SetLevel
  • LevelUp
  • LevelDown
  1. Systems
  2. Stats
  3. Scripting

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();
PreviousStatsNextEvents

Last updated 5 months ago

âš™ī¸