A downloadable tool

Download NowName your own price

About:

This tool started as a common save script I would use in my projects, so I decided to make a simple visual interface and release it online. 

This tool is only a prototype, though I will try to fix any major bugs that it may have, I'm providing this tool for now as-is, without any warranty.

This tool was made with Unity version 2019.3.0f3 and 2020.10f1. I haven't tested it with any earlier versions, but should work with 2018 and possibly 2017 versions.

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.

Legal Stuff:

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 damage or liability.

You are allowed to use and modify this tool for personal use and in any project of yours, even commercially, as long as it is part of a game or software and not by itself.

You may not sell this tool,  distribute it separately or redistribute it.

If you made changes and you would like them to be implemented in the project, DO contact me.

Other:

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.1.unitypackage 16 kB

Development log

Community

3y
by ONCGM · 1 post
3y
Post a new topicView all posts