EditorPrefInterface Class Reference

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.

Public Member Functions

 EditorPrefInterface ()
 Parameterless constructor to create instance- does nothing.
 
void DeleteAll ()
 Removes all keys and values from EditorPrefs. Use with caution.
 
void DeleteKey (string key)
 Removes key and its corresponding value from EditorPrefs.
 
Object GetAssetAtPath (string key)
 Gets the asset reference associated with this key, from prefBase. Behind the scenes, the values are stored as a path (string), and looked up in the Unity AssetDatabase.
 
float GetFloat (string key)
 Returns the value corresponding to key in the preference file if it exists in EditorPrefs.
 
int GetInt (string key)
 Returns the integer value corresponding to key in the preference file if it exists in EditorPrefs.
 
string GetString (string key)
 Returns the string value corresponding to key in the preference file if it exists in EditorPrefs.
 
bool HasKey (string key)
 Returns true if key exists in EditorPrefs.
 
void Save ()
 Writes all modified preferences to disk.
 
void SetAssetPath (string key, Object value)
 Sets the asset reference associated with this key, to the provided bool value.
Behind the scenes, the values are stored as a path (string), and looked up using the provided asset reference in the Unity AssetDatabase. Warning: If the object parameter does not reference a valid Asset, this function will fail without warning or error, and subsequent lookups/gets will yield a null reference.
 
void SetFloat (string key, float value)
 Sets the float value of the preference identified by key to the provided value in EditorPrefs.
 
void SetInt (string key, int value)
 Sets the integer value of the preference identified by key to the provided value in EditorPrefs.
 
void SetString (string key, string value)
 Sets the string value of the preference identified by key to the provided value in EditorPrefs.
 
+ Inheritance diagram for EditorPrefInterface:
+ Collaboration diagram for EditorPrefInterface: