The InspectorGadgets.AutoPrefs class contains a group of nested classes which simplify the way you can store and retrieve values in PlayerPrefs and EditorPrefs.
// First you declare your pref with the key and default value (optional):
public static readonly AutoPrefs.Bool MyPref = new AutoPrefs.Bool("MyPref", true);
// If you don't want to specify a default value, you can use an implicit cast:
public static readonly AutoPrefs.Bool MyOtherPref = "MyOtherPref";
// Then you can get and set the value without using the key everywhere:
if (MyPref)// Or MyPref.Value.
{
MyPref.Value = false;
}
AutoPrefs.Boolstores its value inPlayerPrefswhileAutoPrefs.EditorBoolstores its value inEditorPrefs.- Other pref types are also available:
float,int,string,Vector2,Vector3,Vector4,Quaternion. - You can create your own
AutoPreftypes by inheriting fromAutoPref<T>.