Extended Preferences

Provides the built-in ability to store various classes and structs as keys. DLL_SPECS.

Details

Provides the built-in ability to store various classes and structs as keys (as multiple-keys, transparently) in both UnityEngine.PlayerPrefs and UnityEditor.EditorPrefs. Also provides a framework with which users can easily specify additional classes for storage in PlayerPrefs and EditorPref This modules provides a single interface, IStorePreferences, that can be used to access both Unity's UnityEngine.PlayerPrefs, and UnityEditor.EditorPrefs in a standard way. In particular this is used to reduce code for creation of new multi-key class storage. Though not provided, the IStorePreferences interface could also be used to specify a custom/user-defined method of preference storage, that will automatically work with multi-keys.

Interfaces

The main interfaces provided by this module is the IStorePreferences The interface requires the various functions provided in both unity PlayerPrefs and Unity EditorPref class, as well a few new ones, to get/set values by key. Currently, only two concrete classes implement this interface: PlayerPrefInterface and EditorPrefInterface. But the user can always specify their own, to store preferences in a different manner. The primary class that uses the IStorePreferences interface is the PrefOptionBase class. Though the user will probably want to use that class's two derived variants PlayerPrefOption and EditorPrefOption, it is not mandatory.

Important Classes

The PrefOptionBase class may be derived from by the user to specify how to store a particular class as a multi-key preference. Once defined for a particular type, the PrefOptionArrayBase Variants can be used with it. (If the PrefOptionBase variant for that type has NOT been defined, and it is not provided by the built-in functionality, an exception will be thrown).

ExtensionFunctions

MultikeyPrefHelper provides functions that allow one to get/set specific additional types in Preferences, that require multiple-preference storage elements, to be stored properly. PrefOptionArrayBase can be used to store an array of values in with a single preference key.

ExtendedPrefs Examples

EditorPrefOptionSample.cs PlayerPrefTester.cs

Modules

 EyEengines.ExtendedPrefs.UnityEditor.dll
 ExtendedPrefs dll for use in the Unity Editor.
 
 EyEengines.ExtendedPrefs.dll
 ExtendedPrefs dll for use in built games, and the Unity Editor.
 

Classes

class  EditorPrefInterface
 This class wraps the Unity.EditorPrefs class in the IStorePreferences interface so that it be accessed in the same way as PlayerPrefs. It provides functions that will allow Adding/Deleting/Setting/Getting Editor preferences by Loading/Saving them from/to disk. This class, and Unity EditorPrefs in general are not stored nor available in final, non-editor builds. As such, only Preferences that relate to the Unity editor, and how it functions, should be stored with this class. Another class in this product: PlayerPrefInterface implements the IStorePreferences interface too,but uses Unity's PlayerPrefs class, which IS available in the final build. It should not be necessary for users to directly use this class, unless they wish to create new types of storage functionality, like the EditorPrefOptionArray class does.
 
class  EditorPrefOption< ValueType >
 This class is used to specify a preferences stored via the EditorPrefInterface. It is derived from the PrefOptionBase class.
 
class  EditorPrefOptionArray< ValueType >
 Similar in form to the EditorPrefOptionClass, this class is used to specify a preference that is to be stored as an array of values. Both EditorPrefArrayOption and PlayerPrefOptionArray classes are derived from this one, with each using a specific IStorePreferences interface for the PrefInterfaceType parameter. Unless creating your own IStorePreferences-implementing-class, users should use one of those two derived classes, rather than this one.
 
class  EditorPrefsFromXmlDocs< ValueType >
 The class contains functions for Generated Various Prefs using the fieldName and, for the tool-tip the XMLDocumentataion for the specified field.
 
interface  IAccessPreferences< ValueType >
 All Preference options, via PrefOptionBase, implement this interface. It is used by the PrefOptionBaseEditorDrawingExtensions functions to draw any type of Preference, regardless of which IStorePreferences interface it uses.
 
class  InterfaceTypeDefaults< PrefInterfaceType >
 This static class is used to store a singleton instance for each type of IStorePreferences
 
interface  IStorePreferences
 This Interface is intended to allow consistent access to either Player Preferences(available in final build) or Editor Preferences(available only when running in the editor). Two classes in this Product: EditorPrefInterface, and PlayerPrefInterface implement the IStorePreferences interface, using Unity's EditorPref, and PlayerPref classes respectively.
 
class  MultikeyPrefHelper
 MultikeyPrefHelper provides convenience functions for checking, reading, storing and deleting Vector3, Vector2, Color, and Enums in Unity's preferences storage.
 
class  PlayerPrefInterface
 This class wraps the UnityEngine.PlayerPrefs class in the IStorePreferences interface so that it be accessed in the same way as EditorPrefs. It provides functions that will allow Adding/Deleting/Setting/Getting player preferences by Loading/Saving them from/to disk. Another class in this product: EditorPrefInterface implements the IStorePreferences interface too,but uses Unity's EditorPrefs class. Users of the IStorePreferences interface can uses either of these two concrete classes in exactly the same way.
 
class  PlayerPrefOption< ValueType >
 This class is used to specify preferences stored via the PlayerPrefInterface. It is derived from the PrefOptionBase class. It contains details about the current value of the option, and the Unity PlayerPref key-string of course, but it also contains a default value, and label GUIContent. It provides a Value accessor function, which, along with the constructor, handle loading and saving the value to PlayerPrefInterface for the programmer.
But keep in mind, the load/save operation will be performed every-time Value is accessed: while quite convenient, this could effect performance of loops and such.
 
class  PlayerPrefOptionArray< ValueType >
 This class is used to access preferences stored via the PlayerPrefInterface. It is derived from the PrefOptionBase class. It contains details about the current value of the option, and the key string of course, but it also contains a default value, and label GUIContent. It provides a Value accessor function, which, along with the constructor, handle loading and saving the value to PlayerPrefInterface for the programmer. But keep in mind, the load/save operation will be performed every-time Value is accessed: while quite convenient, this could effect performance of loops and such.
 
class  PrefOptionArrayBase< TValueType, TPrefInterfaceType >
 Similar in form to the PrefOptionBase class, this class is used to specify a preference that is to be stored as an array of values. Both EditorPrefOptionArray and PlayerPrefOptionArray classes are derived from this one, with each using a specific IStorePreferences interface for the PrefInterfaceType parameter. Unless creating your own IStorePreferences-implementing-class, users should use one of those two derived classes, rather than this one.
 
class  PrefOptionBase< ValueType, PrefInterfaceType >
 PrefOptionBase's are used by the programmer to completely specify a "Preference setting" in a standardized manner. Both, the type of value stored, and a concrete type implementing IStorePreferences, are used as generic arguments for this class. When the PrefOption does NOT need to be PrefInterfaceType agnostic: Both EditorPrefOption and PlayerPrefOption classes are derived from this one, with each using a specific IStorePreferences interface for the PrefInterfaceType parameter. Unless creating your own IStorePreferences implementing class, users should usually implement one of those two derived classes, rather than this one. Members contains details about the current value of the option, and the key string which is used to uniquely identify the preference. It also contains a default value, and a display label GUIContent. It provides a Value accessor function, which, does NOT do automatic loading and saving the value to PlayerPrefs for the programmer (thus "manual" in the class name). If you want Load and Save to be automatic, use the derived PlayerPrefOption or EditorPrefOption classes instead.
 
class  PrefsFromXmlDocs< ValueType >
 The class contains functions for Generated Various Prefs using the fieldName and, for the tool-tip the XMLDocumentataion for the specified field.
 
class  XmlPrefOption< TValueType >
 This class is used to specify preferences stored via the PlayerPrefInterface. It is derived from the PrefOptionBase class. It contains details about the current value of the option, and the Unity PlayerPref key-string of course, but it also contains a default value, and label GUIContent. It provides a Value accessor function, which, along with the constructor, handle loading and saving the value to PlayerPrefInterface for the programmer.
But keep in mind, the load/save operation will be performed every-time Value is accessed: while quite convenient, this could effect performance of loops and such.