XmlPreferenceInterface Class Reference

Type of PReference interface that stores preferences to an XML file, rather than the standard unity location for storing PlayerPrefs and EditorPrefs. By default this class uses the application data path for storage of this file, and by default names the file "XMLPrefs.xml". While the static version of this classes functions will always use these options, you may create your own instance of this class, and assign it different path values.

Public Member Functions

 XmlPreferenceInterface ()
 default constructor loads the document and hooks saving the document up to the Application.quitting callback.
 
 XmlPreferenceInterface (string fileName, string filePath)
 Constructor that allows user to specify a custom file and path for used by this interface
 
void DeleteAll ()
 Removes ALL keys and values from the preferences. Use with caution.
 
void DeleteKey (string key)
 Removes key and its corresponding value from the preferences.
 
Object GetAssetAtPath (string key)
 Loads the resource at the path specified in the value associated with this key, from prefBase.
 
float GetFloat (string key)
 Returns the value corresponding to key in the preference file if it exists.
 
int GetInt (string key)
 Returns the value corresponding to key in the preference file if it exists.
 
string GetString (string key)
 Returns the value corresponding to key in the preference file if it exists.
 
bool HasKey (string key)
 Returns true if key exists in the preferences.
 
void Save ()
 Writes all modified preferences to disk.
 
void SetAssetPath (string key, Object value)
 Determines th Path of the Object, and sets the string value of the preference associated with this key to the path.
 
void SetFloat (string key, float value)
 Sets the value of the preference identified by key to the provided value.
 
void SetInt (string key, int value)
 Sets the value of the preference identified by key to the provided value.
 
void SetString (string key, string value)
 Sets the value of the preference identified by key to the provided value.
 

Static Public Member Functions

static void SaveSingleton ()
 Static function used to save changes to the default XmlPreferenceInterface reference.
 

Public Attributes

string filename
 File used to store XmlPreferenceInterface via this instance of XmlPreferenceInterface
 
string filePath
 Path of file used to store XmlPreferenceInterface via this instance of XmlPreferenceInterface
 

Properties

string FullFileNamePath [get]
 Combination of this instance's path and filename as a single string
 
+ Inheritance diagram for XmlPreferenceInterface:
+ Collaboration diagram for XmlPreferenceInterface: