Giter VIP home page Giter VIP logo

prefsgui's Introduction

PrefsGUI

Accessor and GUI set for Unity PlayerPrefs / JSON file

public class PrefsGUISample : PrefsGUISampleBase
{
    [System.Serializable]
    public class PrefsEnum : PrefsParam<EnumSample>
    {
        public PrefsEnum(string key, EnumSample defaultValue = default(EnumSample)) : base(key, defaultValue) { }
    }

    // define PrefsParams with key.
    public PrefsEnum _prefsEnum = new PrefsEnum("PrefsEnum");
    public PrefsString _prefsString = new PrefsString("PrefsString");
    public PrefsInt _prefsInt = new PrefsInt("PrefsInt");
    public PrefsFloat _prefsFloat = new PrefsFloat("PrefsFloat");
    public PrefsBool _prefsBool = new PrefsBool("PrefsBool");
    public PrefsVector2 _prefsVector2 = new PrefsVector2("PrefsVector2");
    public PrefsVector3 _prefsVector3 = new PrefsVector3("PrefsVector3");
    public PrefsVector4 _prefsVector4 = new PrefsVector4("PrefsVector4");
    public PrefsColor _prefsColor = new PrefsColor("PrefsColor");

    protected override void OnGUIInternal()
    {
        _prefsEnum.OnGUI();
        _prefsString.OnGUI();
        _prefsInt.OnGUI();
        _prefsFloat.OnGUI();
        _prefsFloat.OnGUISlider();
        _prefsBool.OnGUI();
        _prefsVector2.OnGUI();
        _prefsVector2.OnGUISlider();
        _prefsVector3.OnGUI();
        _prefsVector3.OnGUISlider();
        _prefsVector4.OnGUI();
        _prefsVector4.OnGUISlider();
        _prefsColor.OnGUI();

        // return true if value was changed
        if ( _prefsColor.OnGUISlider())
        {
            // use as native type
            Color color = _prefsColor;
            Debug.Log("Changed. " + color);
        }

        if (GUILayout.Button("Save")) Prefs.Save();
        if (GUILayout.Button("DeleteAll")) Prefs.DeleteAll();
    }
}

Install

Download a .unitypackage file from Release page.

or

Using Pacakge Manager:
Add following line to the dependencies section in the Packages/manifest.json.

"ga.fuquna.prefsgui": "https://github.com/fuqunaga/PrefsGUI.git"

EditorWindow

  • List up Prefs and can modify
  • You can also feed back the current value as default value
  • You can edit the key prefix for each GameObject by displaying it in order of GameObject

SyncOverUNET

  • auto sync All Prefs
  • You can ignore it by specifying it with EditorWindow

Switch PlayerPrefs / JSON

Switch using at PrefsWrapper.cs https://github.com/fuqunaga/PrefsGUI/blob/master/Assets/Packages/PrefsGUI/Scripts/PrefsWrapper.cs#L5-L6

JSON file path

Application.persistentDataPath + "/Prefs.json"

You can customize by placing PrefsWrapperPathCustom in the scene and set _path field.
also can use the Special folders and enviroment variables.

- %dataPath% -> Application.dataPath
- %companyName% -> Application.companyName
- %productName% -> Application.productName
- other %[word]% -> System.Environment.GetEnvironmentVariable([word])

MaterialPropertyDebugMenu

Auto create material GUI menu

References

MiniJSON
https://gist.github.com/darktable/1411710

prefsgui's People

Contributors

fuqunaga avatar innovative-ideas avatar

Watchers

James Cloos 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.