PlayerPrefInterface Class Reference

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.

Public Member Functions

void DeleteAll ()
 Removes all keys and values from PlayerPrefs. Use with caution.
 
void DeleteKey (string key)
 Removes key and its corresponding value from PlayerPrefs.
 
Object GetAssetAtPath (string key)
 Loads the resource at the path specified in the value associated with this key, from prefBase. Behind the scenes, the values are stored as a path (string), and looked up using the Unity Resources class.
 
float GetFloat (string key)
 Returns the value corresponding to key in the preference file if it exists in PlayerPrefs.
 
int GetInt (string key)
 Returns the value corresponding to key in the preference file if it exists in PlayerPrefs.
 
delegate string GetObjectPathEditorCallback (Object value)
 The delegate specified the function signature of the function the editor put into the editorAdapterVersion member, when the editor is present.
 
string GetString (string key)
 Returns the value corresponding to key in the preference file if it exists in PlayerPrefs.
 
bool HasKey (string key)
 Returns true if key exists in PlayerPrefs.
 
void Save ()
 Writes all modified PlayerPrefs to disk. Note: PlayerPrefs are automatically saved by Unity onApplicationQuit.
 
void SetAssetPath (string key, Object value)
 PlayerPrefs cannot determine the resource path of an object reference. In the final build, use the SetPreFabPath version that takes a string for the second parameter, to manually assign the path of the resource." When running in the editor, it will attempt to find the objects path using UnityEditor.AssetDatabase.GetAssetPath.
 
void SetAssetPath (string key, string path)
 PlayerPrefs cannot determine the path of an object. Uses SetString, with the same key, to manually provide the path of the resource."
 
void SetFloat (string key, float value)
 Sets the value of the preference identified by key to the provided value in PlayerPrefs.
 
void SetInt (string key, int value)
 Sets the value of the preference identified by key to the provided value in PlayerPrefs.
 
void SetString (string key, string value)
 Sets the value of the preference identified by key to the provided value in PlayerPrefs.
 

Static Public Attributes

static GetObjectPathEditorCallback editorAdapterVersion
 When the editor is present this delegate reference will be automatically populated with a valid Editor-DLL function. The function can then be invoked during normal operation and will either do nothing(final build), or invoke the editor function(running in editor), as appropriate.
 
+ Inheritance diagram for PlayerPrefInterface:
+ Collaboration diagram for PlayerPrefInterface: