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.


Note: This feature has been introduced in version 2.8.0
Sometimes you need to save your data securely that no one else can modify it to cheat your game, so you need encryption in this case that Save Game Pro uses AES encryption, first of all you need to enable encryption in Save Game Pro but settings Encrypt property of SaveGameSettings to true, like this:

Or you can change the default settings and enable encryption globally for all Save calls:

Was this article helpful to you? Yes 4 No 2

How can we help?