1. Home
  2. Docs
  3. Save Game Pro
  4. Tutorials
  5. Basic Saving and Loading

Basic Saving and Loading

First, you need to add  using BayatGames.SaveGamePro;  at top of your script to use Save Game Pro API.

Here is a simple usage example of Save Game Pro by saving and loading a simple integer value:

As you can see, Save Game Pro saves values using identifiers and allows you to load desired value using the specified identifier.

Now, let us save some more complex data, let us save a struct:

Also, you can save Almost All Components:

We have two kinds of saving and loading, saving and loading by Value and saving and loading by Reference.

Saving and Loading by Value

Most of the types are Value types, such as Primitives, Non-MonoBehaviour classes, Structs, … these data types can be saved by value:

Note: All classes, except MonoBehaviours and Unity Objects, can be saved and loaded by both Reference and Value, a good example for this type of data is Mesh class, this class can be stored as Value or Reference and loaded as Value or Reference without any problem:

Saving and Loading by Reference

You can save and load all classes and components by reference because the Classes are Reference Types in C# and any change to the reference reflects the source:

Note: It is not recommended to save and load MonoBehaviours, Components, Unity Objects, … by Value, because they will be instantiated as needed.

Was this article helpful to you? Yes 2 No 1

How can we help?