Skip to main content

SettingsFieldAccess<TFieldType>

An abstract class in Root.Township, Alta.Utilities.

An asset that reads and writes one named property of GameSettings or ServerSettings by reflection. Used by quick access menu and settings UI entries.

Constructors​

MemberWhat it is
protected SettingsFieldAccess()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

4 private and internal fields
MemberWhat it is
private string fieldNameName of the public property on GameSettings or ServerSettings to read and write.
private bool isServerSettingIf true the property is looked up on ServerSettings, otherwise on GameSettings.
private PropertyInfo propertyCached reflected property. Backing field for Property.
private string settingDescriptionDescription text for the setting. Backing field for SettingDescription.

Properties​

MemberWhat it is
override string SettingDescription { get; }Description text set in the asset.
protected PropertyInfo Property { get; }The reflected property, looked up by field name on GameSettings or ServerSettings. Falls back to game settings if none were set.

Methods​

MemberWhat it is
virtual TFieldType GetValue()Reads the property from the current settings object.
override bool IsValid()True if the named property exists on the settings type.
virtual void SetValue(TFieldType value)Writes the property, then (for game settings) notifies listeners and saves the game config.