To create a save data class you’ll need to setup for variables for the class to contain. To start you’ll need to press the add field button to add your first variable.
Creating a variable
Once you have added a field, you be presented with a grouping of fields to edit for this variable like what you can see on the left here. There are 4 options that the field will show by default, but this varies on the setup. Each grouping will always have:
- Variable Name – Which is what the variable will be called.
- Data Type – Which is the data type the variable is defined as.
- Collection Type – Which defines whether this variable is a collection like a list, array, queue, stack or if it is a normal single variable.
If the data type is a class value then an extra field will appear for the class name, which is where you’d but the name of the class you want the variable to be of. This field is CaSe SeNiStIvE!
If you have the grouping with no collection type then a field will be available for a default value. This can be left blank or have a value that is valid for the type. The field will adjust based on the data type you have selected.
⚠️ Note: Sprites & Classes can’t have a default value.
You can keep adding more variables with the + Add Field button or the green + button next to each grouping and remove a grouping with the red – button.
Generating the class for use
Once you have filled in the variables you want to save, you can press the Generate New SaveData Class button to make the class with the inputs you gave. At this point the editor will refresh with the class will be placed in the following directory in your project, please delete the SaveData.cs class provided in asset package if you haven’t already at this point as it is no longer needed:
What setups are valid?
If your making your save data class yourself or editing the code generated after using the tool there are some important steps to follow to keep the save data valid. You’ll note that when you save any Vectors, Colors, Quaternions & Sprites that their datatype has the prefix of Save before it. This is out custom struct for saving these types of data. Previously you would’ve had to use these types in your code, however since 1.1.0 you can now just use the normal version and use the implicit operator to convert them to and from the save variants. So if you are writing your own class for the save manager to use you will need to use the save variants for these types which are listed below for reference:
Exposure & Default Values
Every field you add must be public for the tool to work correctly, you’ll want this too as there isn’t much point of having private values in a save file. The only other issue you’ll find is with default values. By default we only support default values when defining values as a single variable and not a collection (list, array etc.). We also don’t support default values for sprites and classes. This is mostly due to the amount of backend work that would be need to make it work and the lack of instances where you’d want to use it. If you want to edit the default values outside of the editor you’ll have to note that they should be written in their raw form, for example you might use Vector2.One as the default value. This won’t work with our editor, so you should write it as new Vector2(1f,1f) instead.
Extra Setup For Saving Sprites
To save sprites you need to have you sprite asset import settings setup up in a particular way. Thankfully its nice and simple, in the import settings you need to enable the read/write toggle as well as not using any compression on the sprite you plan to save. Because of the lack of compression we advice you to use Power of 2 (256×256, 512×512, 1024×1024 etc) where possible and compress the art outside of Unity to help mitigate this issue if art file size is a problem for your product.
The About Tab
The about tab provides a little more info on the asset as well as the version number, release data and some useful links for the asset. These include a button to this documentation page, a button to open the invite to our discord server and a button to our report form to report issues with the asset and any of our other products to us.