A class in Root.Township, Alta.Utilities.
Settings field access for an enum setting, offered as a list of names. Can show custom display names, matched to the enum values by order.
Constructors
| Member | What it is |
|---|
EnumGameSettingAccess() | Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets. |
Fields
5 private and internal fields
| Member | What it is |
|---|
private string[] customNames | Display names, in the enum's order. |
private Dictionary<string, string> customToEnumNames | Backing field for CustomToEnumNames. |
private Dictionary<string, string> enumToCustomNames | Backing field for EnumToCustomNames. |
private bool isSetup | Set once the name maps are built. Nothing reads it. |
private bool isUsingCustomNames | Whether to show customNames instead of the enum names. |
Properties
2 private and internal properties
| Member | What it is |
|---|
private Dictionary<string, string> CustomToEnumNames { get; } | Display name to enum name map, built on first use. |
private Dictionary<string, string> EnumToCustomNames { get; } | Enum name to display name map, built on first use. |
Methods
| Member | What it is |
|---|
override async Task<string[]> GetPossibleValue() | The option names: the custom names if turned on, otherwise the enum's names. |
override string GetValue() | The current value as a name (the custom name if turned on). |
override void SetValue(string value) | Parses the name (mapping a custom name back first), sets the property and raises OnModifed. |
2 private and internal methods
| Member | What it is |
|---|
private void OnValidate() | Editor: fills the custom names from the enum names when custom names are on but empty. |
private void SetupCustomNameMappings() | Builds both name maps by index. Needs one custom name per enum value. |