# Saving & Loading Stats

`UnitStats` and `Stat` are serializable classes; thus, they can be saved by most save systems. If you're looking for a save system, try [ESave](https://app.gitbook.com/s/korEE1oahhwAkGIn7ek0/getting-started/installation)—it has been tested with Skill Tree, and it's free!

Since every save system may be different, this example will only show you how stats can be saved with ESave.

## Saving Stats

<pre class="language-csharp"><code class="lang-csharp"><strong>// Get the save file reference
</strong><strong>var saveFile = GetComponent&#x3C;SaveFileSetup>().saveFile;
</strong><strong>
</strong><strong>// Where unitStats is a UnitStats object (this can be obtained from a UnitStatsProvider)
</strong>// Save the data
saveFile.AddOrUpdateData("stats", unitStats);
saveFile.Save();
</code></pre>

## Loading Stats

```csharp
// Get the save file reference
var saveFile = GetComponent<SaveFileSetup>().saveFile;

// Load the stats
var unitStats = saveFile.GetData<UnitStats>("stats");

// Where statsProvider is a UnitStatsProvider object
// Set the data to the provider
statsProvider.data = unitStats;
statsProvider.Refresh();
```

Learn more about ESave [here](https://app.gitbook.com/s/korEE1oahhwAkGIn7ek0/getting-started/installation).
