If you’d like to store values in a freeform way, like you would with PlayerPrefs, you can do that by using the GDE Data API directly. There are Get and Set methods for each basic type, and generic methods for Unity types.
These are the same methods used by the GDE Generated Data Classes. You can call these methods directly to read data from your items without the use of the GDE Data classes. To read or write data of GDE items, the key is the item ID, and the field is the field name you’d like to access.
Get basic types like this:
bool singleBool = GDEDataManager.GetBool(key, field, defaultValue); List<string> listStr = GDEDataManager.GetStringList(key, field, defaultList); List<List<float>> list2DFloat = GDEDataManager.GetFloatTwoDList(key, field, default2dList); // etc for all the basic types
Get Unity types like this:
GameObject go = GDEDataManager.GetUnityObject<GameObject>(key, field, defaultValue); List<Texture2D> texList = GDEDataManager.GetUnityObjectList<Texture2D>(key, field, defaultList); List<List<Material>> mat2DList = GDEDataManager.GetUnityObjectTwoDList<Material>(key, field, default2dList);
Set methods are similar to Get methods, but have no return values.
GDEDataManager.SetBool(key, field, boolValue); GDEDataManager.SetStringList(key, field, strList); GDEDataManager.SetFloatTwoDList(key, field, float2dlist);
Note: Unity types are read only in v2.6. Generic Set methods for Unity types are available, but do not provide an implementation. Fell free to implement these methods if you like. I’m always open to suggestions so if you come up with something that you’d like to see in the official package, send me an email.
Suppose you wanted to save some global game settings. You could do so by using "GameSettings" as the key, and set the Field to the particular setting. For example:
// To save a language preference GDEDataManager.SetString("GameSettings", "language", "en"); // Or set volume settings GDEDataManager.SetBool("GameSettings", "muted", isMuted); GDEDataManager.SetFloat("GameSettings", "volume", volume);
To read those settings, use the Get methods:
// To read the selected language string selectedLanguage = GDEDataManager.GetString("GameSettings", "language", defaultLanguage); // Or get the volume settings bool isMuted = GDEDataManager.GetBool("GameSettings", "muted", false); float volumeLevel = GDEDataManager.GetFloat("GameSettings", "volume", 1f);