A downloadable tool for Windows, macOS, Linux, and Android

Download NowName your own price

About:

This tool started as a common save script I used in my projects, as it grew bigger, I decided to make it its own project, document it and add a visual interface to release it online for others to use it as well.

The tool is also dev friendly, as it can save in three main formats, JSON, XML and binary. So you can check things out easily during development and ship the game with the data hidden from most players with a single click.

The save is not encrypted though, the binary is just to discourage the players from simply changing values with a text editor, as this format needs some extra knowledge to edit.

This tool was made with Unity version 2019.3.0f3 - 2020.10f1 and worked when tested on 2022.3.26f1.

I haven't tested it with any earlier versions, but should work with 2018 and possibly 2017 versions. I tried it out recently with Unity version 2022.3.26f1 and it worked without problems, so I am inclined to say it will work on editor versions 2018 through 2022.

How to:

The tool is very simple, the panel controls the settings, which can be also set by code, and allows you to create a file, delete it, and check the files folder. Everything else will be done by code, E.g. triggering a save or loading some data.

To open the window, on Unity Engine, the top bar of options, there will be an option called 'ONCGM', there you can open the Save System window.

On this part, you can select the location and save format.


Here you can choose your file and directory name as well as set the auto save feature.

This is the list that will display all of the files that the system was able to find.


On the bottom of the window, there are some utility tools and you can choose the language of the tool here as well as delete all of the files, so be careful.



However, I do not know what your needs are, so to accommodate for that, you can customize the 'SaveData' class to your liking. That being the case, you'll need to create variables to reflect the things you will need to serialize in your game.

I've provided a few examples variables in the default 'SaveData' class.

It will serialize strings, int, float, bool, arrays and most of the basic types. If it does not support the variable type, you should see an error on the console.

Methods.
SaveSystem.AutoSave()Auto saves the current loaded data.
SaveSystem.CheckForDirectory() Checks if the game folder exists.
SaveSystem.CheckForSaveFile()
SaveSystem.CheckForSaveFile(string path)
Checks if a save file exists.
May receive a string to specify
the file to be checked.
SaveSystem.CreateDirectory()Creates the game save folder if it does not exists.
SaveSystem.DeleteFile(string path) Deletes the specified file.
SaveSystem.DeleteLoadedFile()Deletes the current loaded file.
SaveSystem.ExitSave()SaveSystem.ExitSave([NotNull] SaveData data)Save the current loaded data or the specified 'SaveData'.
 Uses a different name to distinguish it from a normal or auto save.
SaveSystem.LoadAutoSave() SaveSystem.LoadAutoSave(string fileName)// Loads the most recent auto save. // Or loads the specified auto save file.
SaveSystem.LoadExitSave();// Loads the most recent exit save.
SaveSystem.LoadGameFile() SaveSystem.LoadGameFile(SavePath path)

SaveSystem.LoadGameFile(SavePath path, string name, SaveFormat format)

 SaveSystem.LoadGameFile(string path, SaveFormat format)

SaveSystem.LoadGameFile(string path)
Will load the most recent save file into the 'loadedFile' variable.
Has various overrides so you can be more specific about what file you want.
SaveSystem.SerializeToFile()

SaveSystem.SerializeToFile(string fileName, bool appendDateAsSuffix)

SaveSystem.SerializeToFile(string fileName, SaveFormat format, SavePath path, bool appendDateAsSuffix)

SerializeToFile([NotNull] SaveData data, SaveFormat format, SavePath path, bool appendDateAsSuffix)

SerializeToFile(string name, [NotNull] SaveData data, SaveFormat format, string path, bool appendDateAsSuffix)


Saves the loaded data using the set methods in the save settings. (See Save System window to change the settings).
 This method will overwrite the save file in which the loaded data was read from.
If loaded data is a null it will ignore the request,  to create a new save use one of the overloads and pass a 'new SaveData()' as a parameter. 
SaveSystem.SetAutoSave(bool enableAutoSave, AutoSaveInterval timeInterval, bool hideAutoSaveFile)Toggles the auto save on or off.
SaveSystem.SearchForSaveFiles()Searches for any save file in the known directories.
SaveSystem.SetSaveSystemSettings(SaveSystemSettings updatedSettings)Changes the save system settings.
SaveSystem.UpdateDirectory()Updates the game folder to be the same of the one in the settings file.
Variables and Enumerators.
type of List<SaveData>
SaveSystem.AutoSaves
Holds data of all the auto saves found.
type of List<FileInfo>
SaveSystem.AutoSavesInfo
Holds information on all of the auto saves files found.
type of List<SaveData>
SaveSystem.GameSaves
Holds data for all of the save files found.
type of List<FileInfo>
SaveSystem.GameSavesInfo
Holds information on all of the save files found
type of SaveDataSaveSystem.LoadedDataThe active save data. Use this to modify the values you need, then save it.
type of FileInfo
SaveSystem.LoadedDataInfo
Information of the current loaded save date file.
enum UserInterfaceLanguageDefines the language available for use in the save system editor window.
enum SavePathDefines the paths that the system can serialize files to.
enum SaveFormatDefines the format in which to save files as.
enum AutoSaveIntervalDefines set time intervals for the auto save feature.
Here's a basic example of how to store data in the active 'SaveData' class and serializing it.
using ONCGM.Utility; 
using UnityEngine; 
using UnityEngine.UI;  
public class VolumeUI : MonoBehaviour {
     private SaveData playerData;
     public Slider musicVolumeSlider;
      // Read data from file and set UI to match the loaded values.
     private void Start() {
         SaveSystem.LoadGameFile();
         playerData = SaveSystem.LoadedData;
         musicVolumeSlider.value = playerData.musicVolume;
     }
      // Updates the music volume value from UI slider and saves changes.
     public void UpdateMusicVolume(float value) {
         playerData.musicVolume = value;
         SaveChanges();
     }
      // Save changes to file.
     private void SaveChanges() {
         SaveSystem.LoadedData = playerData;
         SaveSystem.SerializeToFile();
          // Consider using a timer to avoid saving multiple times in a short interval.
         // i.e., if (Time.time < lastTimeOfSave + delayBetweenSaves);
     }
}


One thing to be careful is if you try to load a file with an outdated data structure.
For instance, you've added more variables to your save and now you're trying to load it, this will cause an error.
To avoid this you will need to either delete the old data and create a new save or write a custom parser to import it into the newer data class and adapt the save file.

I might add this in the future when I need to do something like this on one of my own projects. If you're interested in this, let me know.

Although I will try to fix any major bugs that it may have, I'm providing this tool  "as is", without any warranty.

Legal Stuff:

If you have acquired a copy of the tool without source code:

  • You are allowed to use tool for personal use and in any project of yours, even commercially, as long as it is integrated into a game or software product.
  • You are not allowed to modify and / or change the tool in any way, except the "SaveData .cs" class file.
  • You may not sell, distribute or redistribute the tool by itself or sell it incrementally.
  • All rights to the source code remain with the owner.
  • You are granted a license to use and integrate the tool into your projects, but you do not obtain ownership of the source code.

If you have acquired a copy of the tool with source code:

  • You are allowed to use this tool for personal use and in any project of yours, even commercially, as long as it is integrated into a game or software product.
  • You are allowed to modify the tool to fit your project.
  • You may not sell, distribute or redistribute the tool by itself or sell it incrementally.
  • All rights to the source code remain with the owner. 
  • You are granted a license to use, modify, and integrate the tool into your projects, but you do not obtain ownership of the source code.

This tool is being provided as-is, without any warranty of any kind. 

In no way, shape, form or event shall the owner or distributor of the software be liable for any damages or liabilities arising from its use.

For major or long-term support (LTS) projects, please reach out to discuss more in-depth look into the usage or any other requests catering to your project.

The owner reserves the right to modify these terms at any time, at their sole discretion and for any reason. Users will be notified prior to any changes through appropriate channels.

Continued use of the tool after any such changes shall constitute your consent to such changes.

This tool is not sponsored by or affiliated with Unity Technologies or its affiliates. Unity” is a registered trademark of Unity Technologies or its affiliates in the U.S. and elsewhere.

Download

Download NowName your own price

Click download now to get access to the following files:

ONCGM's Save System 1.0.2.unitypackage 17 kB
ONCGM's Save System 1.0.2 - Source Code.unitypackage 14 kB
if you pay $147.95 USD or more

Development log

Leave a comment

Log in with itch.io to leave a comment.