Skip to content

Quickly Save/Load data in Binary or Json formats, and Encrypt it in Unity

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta
Notifications You must be signed in to change notification settings

belzecue/UnitySaveLoad

 
 

Repository files navigation

Welcome to com.gameframe.saveload 👋

Version Twitter: coryleach

This is a simple utility for quickly saving and loading objects to disk in unity.

Supports Binary, UnityJson, and JsonDotNet.
Optionally you can select an encrypted version of each of the above.
Additionally custom serialization methods are supported using the ISerializationMethod interface.
JsonDotNet support requires the Json.Net for Unity asset store package or Newtonsoft's Json.
For info on enabling JsonDotNet support see the Enable Json.Net Support section of this readme.

Quick Package Install

Using UnityPackageManager (for Unity 2019.3 or later)

Open the package manager window (menu: Window > Package Manager)
Select "Add package from git URL...", fill in the pop-up with the following link:
https://github.com/coryleach/UnitySaveLoad.git#1.0.1

Using UnityPackageManager (for Unity 2019.1 or later)

Find the manifest.json file in the Packages folder of your project and edit it to look like this:

{
  "dependencies": {
    "com.gameframe.saveload": "https://github.com/coryleach/UnitySaveLoad.git#1.0.1",
    ...
  },
}

Usage

SaveLoadManager is not a singleton. Multiple instances may be used and created.
In the project tab menu select Create->Gameframe->SaveLoad->SaveLoadManager
This will create an instance of a SaveLoadManager asset.
Select the created object and configure options via the inspector.

//Use the Project tab's create menu GameFrame->SaveLoad->SaveLoadManager to create a manager
//You can then use public or serialized fields to reference your save system.
// OR
//Create a Manager at Runtime like this
manager = SaveLoadManager.Create("BaseDirectory","SaveDirectory",SerializationMethod.Default);

//Save object to disk in a file named "MySave.data"
manager.Save("MySave.data",objectToBeSaved);

//Load from disk
//loadedObject will be null if the file does not exist
var loadedObject = manager.Load<SavedObjectType>("MySave.data");

//Delete saved file
manager.DeleteSave("MySave.data");

//Setup a Custom Save/Load Method by passing any object that implements ISerializationMethod
manager.SetCustomSerializationMethod(new MyCustomSerializationMethod());

//Save a ScriptableObject or any object derived from UnityEngine.Object directly to disk
var myScriptableObject = ScriptableObject.CreateInstance<MyScriptableObjectType>();
manager.SaveUnityObject(myScriptableObject,"MyUnityObjectData.dat");

//Loading a UnityEngine.Object type requires an existing object to overwrite
//The following method will overwrite all the serialized fields on myScriptableObject with values loaded from disk
manager.LoadUnityObjectOverwrite(myScriptableObject,"MyUnityObjectData.data");

Enable Json.Net Support

Ensure the Json.Net for Unity package has been imported.
In player settings add the string 'JSON_DOT_NET' to Scripting Define Symbols.

Author

👤 Cory Leach

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

About

Quickly Save/Load data in Binary or Json formats, and Encrypt it in Unity

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%