Changes

Jump to navigation Jump to search
Line 90: Line 90:  
= Saving and loading data =
 
= Saving and loading data =
 
== Global data ==
 
== Global data ==
All '''ModBehaviours''' have the '''SaveSetting''' and '''LoadSetting''' method to save data globally. Note that '''SaveSetting''' and '''LoadSetting''' are generic and will call ToString() and try to convert the saved string to the data type you specify, so this will only work for simple types, like integers, floats, doubles, bools, strings, etc. To load something back, use '''LoadSetting<type>("Key", defaultvalue)''', e.g. '''LoadSetting<bool>("Notifications", false)'''. There's also '''TryLoadSetting''', if you want to handle when the setting doesn't exist and '''DeleteSetting''' to remove existing settings.
+
All '''ModBehaviours''' have the '''SaveSetting''' and '''LoadSetting''' method to save data globally.
 +
 
 +
Note that '''SaveSetting''' and '''LoadSetting''' are generic and will call ToString() and try to convert the saved string to the data type you specify, so this will only work for simple types, like integers, floats, doubles, bools, strings, etc. To load something back, use '''LoadSetting<type>("Key", defaultvalue)''', e.g. '''LoadSetting<bool>("Notifications", false)''' or '''LoadSetting("Notifications", false)''', since bool is implicit from using '''false'''.
 +
 
 +
There's also '''TryLoadSetting''', if you want to handle when the setting doesn't exist and '''DeleteSetting''' to remove existing settings.
    
== Per save data ==
 
== Per save data ==

Navigation menu