Skip to content

Async load / save local data with compression, encryption and integrity check.

License

Notifications You must be signed in to change notification settings

FronkonGames/GameWork-Local-Data

Repository files navigation

Async Load/Save Local Data With Compression, Encryption And Integrity Check


version license top language code quality

'Local Data' is a module of 'Game:Work' dedicated to read and write local files asynchronously.

Features 🎇

  • Fully asynchronous read, load and cancel.
  • Integrity check using MD5, SHA-1, SHA-256 or SHA-512 algorithms.
  • Compression / decompression using algorithms: GZip, Zip or Brotli.
  • Encryption / decryption using algorithms: AES, DES, RC2, DES or TripleDES.
  • Supports typical Unity data such as: Vector, Quaternion, Color, etc.

Requisites 🔧

Installation 📦️

Editing your 'manifest.json'

  • Open the manifest.json file of your Unity project.
  • In the section "dependencies" add:
{
  ...
  "dependencies":
  {
    ...
    "FronkonGames.GameWork.Modules.LocalData": "git+https://github.com/FronkonGames/GameWork-Local-Data.git",
    "FronkonGames.GameWork.Core": "git+https://github.com/FronkonGames/GameWork-Core.git",
    "FronkonGames.GameWork.Foundation": "git+https://github.com/FronkonGames/GameWork-Foundation.git"
  }
  ...
}

Git

First clone the dependencies inside your Assets folder:

git clone https://github.com/FronkonGames/GameWork-Foundation.git

git clone https://github.com/FronkonGames/GameWork-Core.git

Then clone the repository:

git clone https://github.com/FronkonGames/GameWork-Local-Data.git

Use 🚀

Create a class inheriting from ILocalData and add the attribute Serializable:

[Serializable]
public class MyLocalData : ILocalData
{
  public string Signature => "MySignature";
  
  public string playerName = "Guybrush Threepwood";
  
  public Vector3 position = new(0.0f, -10.0f, 0.0f);
}

To serialize it in the file 'Guy.brush':

localDataModule.Write(myLocalData, "Guy.brush", null, (result) =>
{
  if (result == FileResult.Ok)
    Debug.Log("Guybrush Threepwood saved!");
  else
    Debug.Error($"{result} writing 'Guy.brush'.");
});

To deserialise the file 'Guy.brush' into an object:

MyLocalData myLocaldata = null;

localDataModule.Read<MyLocalData>("Guy.brush", null, (result, file) =>
{
  if (result == FileResult.Ok)
    myLocalData = file;
  else
    Debug.Error($"{result} reading 'Guy.brush'.");
});

License 📜

Code released under MIT License.

Releases

No releases published

Packages

No packages published

Languages