Settings are managed by the Settings Service (
GameService.Settings) and are saved to
settings.json. Settings are manged with the
Settings.SettingEntry<T> class and are contained within a
SettingCollection supports containing other
SettingCollection allowing you to better organize your settings.
All types are technically supported as long as they are serializable. The following types will, however, provide the best experience:
- Any enum
Settings can be defined at any time. Once defined, they are kept in
settings.json if their value is different from the defined default.
The best time to define module settings is in the
DefineSettings method. The
settings parameter is the root
SettingCollection associated with your module. You can add as many settings and collections as you would like within this collection.
DefineSettings(string entryKey, T defaultValue, Func<string> displayNameFunc = null, Func<string> descriptionFunc = null)
- entryKey is the unique name of the setting within the collection. Each setting within a
SettingCollectionmust have a unique
- defaultValue is the default or initial value of the setting.
- displayNameFunc is the friendly display name used when the setting is rendered within the UI. It is provided as a function which returns a string to ensure it is localization friendly.
- descriptionFunc is the setting description which is shown when the mouse hovers over a rendered setting within the UI. It is provided as a function which returns a string to ensure it is localization friendly.
For internal settings managed manually by your module, you do not need to define
descriptionFunc as they are only used when displayed within the UI by a
AddSubCollection(string collectionKey, bool renderInUi)
- collectionKey is the unique name of the new sub collection within the collection. No different than the
entryKeywhen defining settings.
- renderInUi if
true, the subcollection will automatically render itself when a parent collection is rendered. If
false, the subcollection will be ignored if the parent collection is rendered to the UI.
Some settings, in context, need to be limited in some way when displayed in the UI.
float setting entries can set the allowed range for the value using
SetRange(minValue, maxValue);. When the setting is rendered, the TrackBar control which allows changing the value will be limited to the range you've set with
Settings that are automatically rendered can have their associated control disabled in the UI using
SetIncluded / SetExcluded
Allows you to limit the list of enums made available to a setting using
SetIncluded(Enum1.Value1, Enum1.Value2, ...);.
Supported setting types (listed below) can be automatically rendered to a view. To do this, pass a
SettingCollection in the constructor of a
'First Class' Types
Only some types support automatically generating controls to manage the setting. For instance, a bool setting can be automatically rendered to a checkbox control.