Code Monkey home page Code Monkey logo

gamework-local-data's Introduction

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.

gamework-local-data's People

Contributors

fronkongames avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kijou

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.