Skip to main content

OverridableSettings

An abstract class in Root.Township, the global namespace.

Base for settings assets where one asset can override chosen fields of another. GetOverridenSettings builds and caches a copy of the base with the selected fields taken from this asset.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private static Dictionary<OverridableSettings, OverridableSettings> instantiatedSettingsCache of built override copies, keyed by the overriding asset.
private bool isOverridingSettingsBacking field for IsOverridingSettings.
private List<string> selectedFieldsNamesBacking field for SelectedFieldsNames.

Properties​

MemberWhat it is
bool IsOverridingSettings { get; set; }Whether this asset is set up as an override. Set in the editor.
List<string> SelectedFieldsNames { get; set; }Names of the fields this asset overrides on the base settings.

Methods​

MemberWhat it is
T GetOverridenSettings<T>(T baseSettings)Returns a cached copy of the base settings with each selected field copied from this asset, by reflection.
T GetSettingsObject<T>()Returns this asset cast to the requested settings type.