Code Monkey home page Code Monkey logo

unityalternativeplayerprefs's Introduction

APlayerPrefs

This Unity library is designed to replace the standard Unity PlayerPrefs.

The main difference is that it saves all records in JSON format to a file in Application.persistentDataPath. For this, the JSON.Net resource, available for free at the asset store, was used.

This makes it much easier to store your save games data in places like the Steam Cloud services, iCloud, Google Play or your own backend etc ..

The Library also adds some functionality such as extra record types and more refined / flexible data access.

Tested on Windows and Android.

Installation

Grab the latest unity package from the releases tab of this repo and import it into your project.

Settings

Just go to APlayerPrefs > Settings menu. It is possible to configure the name of the saved file, if it will have automatic saving and the interval time of each save.

[Menu Settings

[Inspector Settings

Usage

Setup

Use APlayerPrefs.Setup(); in any MonoBehaviour to initialize and configure APlayerPrefs.

Set

APlayerPrefs.SetString(string key, string value);
APlayerPrefs.SetInt(string key, int value);
APlayerPrefs.SetFloat(string key, float value);
APlayerPrefs.SetDouble(string key, double value);
APlayerPrefs.SetLong(string key, long value);
APlayerPrefs.SetBool(string key, string value);
APlayerPrefs.SaveObject<T>(string key, T value);

Get

APlayerPrefs.GetString(string key);
APlayerPrefs.GetInt(string key);
APlayerPrefs.GetFloat(string key);
APlayerPrefs.GetDuble(string key);
APlayerPrefs.GetLong(string key);
APlayerPrefs.GetBool(string key);
APlayerPrefs.GetObject<T>(string key);

Utils

APlayerPrefs.Save();
APlayerPrefs.HasKey(string key);
APlayerPrefs.DeleteAll();
APlayerPrefs.Deletekey();

Manual File writing

At the top of FileBasedPrefs.cs is a bool named AUTO_SAVE;

If set to true (the default setting), it will save the data for the time interval defined in DELAY_SAVE.

If set to false, then it will only save the data to file when you call APlayerPrefs.Save();

This means that the save data is stored in memory until you specifically tell it to write the file. This is much faster and causes no performance issues.

Edit Util

You can open the directory where the file was saved and you can clear all data from the file.

[Edit Util

unityalternativeplayerprefs's People

Contributors

dands-salaun avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.