Giter Site home page Giter Site logo

unityiniextension's Introduction

UnityIniExtension

UnityIni is a mini library for serializing object properties to ini configuration files in unity. ini is great because it's fast to parse, and allows the player or modders to easily change game settings. The underlying Config class, which IniSerializeable inherits from, can also be used to support other file formats.

This library saves files to Application.persistentDataPath asynchronously, and uses TextAsset objects for loading initial default configuration files. To use default files drag an .ini.txt file from your Assets folder into a GameObject with a TextAssets component.

Serialization example:

class PlayerSettings : IniSerializeable
{
    public float maxHealth;

    public PlayerSettings()
        : base("player.ini") { }

    public override void Deserialize() {
        base.Deserialize(); // important, loads file data
        maxHealth = LoadFloat("Status", "fMaxHealth"); // Load data
        Destroy(); // data no longer needed
    }

    public override void Serialize() {
        base.Serialize() // important, makes sure data is not null
        Store("Status", "fMaxHealth", maxHealth); // store data
    }
}

Dynamic serialization example:

class Player
{
    class PlayerSettings : IniSerializeable
    {
        public PlayerSettings()
            : base("player.ini") { }
    }

    void Start() {
        var settings = new PlayerSettings();
        float health = settings.LoadFloat("Status", "fMaxHealth");
    }
}

Serialize and save all configuration files to disk:

void OnApplicationQuit() {
    Config.SaveAllAsync();
}

For more examples check out the examples directory

unityiniextension's People

Contributors

stillwwater avatar

Stargazers

Endar avatar  avatar  avatar Mirza Sohail Ali Baig avatar Mr.Hu avatar Luka Kostić avatar

Watchers

James Cloos avatar  avatar

Forkers

jorik041

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.