Class UiOptionRules
Canonical, engine-agnostic UI-option validity rules: which UiComponentInteractionTypes are
allowed for a given UiComponentValueType, whether an option's serialized bindings
(GameSettings id/guid, action guid, transition target) are internally consistent, whether a GameSettings
value type is compatible with a UI value type, and duplicate-option-id detection. Previously this ruleset
existed only in editor code (UnityMenuOptionEditorState) and was independently re-implemented at
runtime (UnityMenuOptionRuntimeSafety) and in the options-list inspector
(UiOptionListInspectorGUI.AreMachingTypes) -- meaning a recipe-created invalid option was never
caught outside the editor inspector. Editor, runtime, and inspector code should all delegate here so the
rule is defined exactly once.
Inherited Members
Namespace: Serenity.Menu.Application.Validation
Assembly: Serenity.Menu.Application.dll
Syntax
public static class UiOptionRules
Methods
AreMatchingTypes(GameSettingsValueType, UiComponentValueType)
Determines whether a GameSettings value type is compatible with a UI component value type (used to bind an option to a GameSettings asset, and to filter which GameSettings assets a picker offers).
Declaration
public static bool AreMatchingTypes(GameSettingsValueType gameSettingsType, UiComponentValueType uiValueType)
Parameters
| Type | Name | Description |
|---|---|---|
| GameSettingsValueType | gameSettingsType | The candidate GameSettings asset's value type. |
| UiComponentValueType | uiValueType | The option's UI value type. |
Returns
| Type | Description |
|---|---|
| bool | True when the types are compatible. |
FindDuplicateOptionIds(IReadOnlyList<UiOption>)
Finds option ids that appear more than once in the given options. Ids must be unique within a single menu/modal (runtime resolves an option's GameSettings binding, and duplicate detection in the editor, by this id).
Declaration
public static List<string> FindDuplicateOptionIds(IReadOnlyList<UiOption> options)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<UiOption> | options | The options to scan (may be null or contain nulls). |
Returns
| Type | Description |
|---|---|
| List<string> | The distinct ids that occur more than once, in first-seen order. |
GetAllowedInteractionTypes(UiComponentValueType)
Returns the interaction types that are valid for the given UI component value type.
Declaration
public static IReadOnlyList<UiComponentInteractionType> GetAllowedInteractionTypes(UiComponentValueType valueType)
Parameters
| Type | Name | Description |
|---|---|---|
| UiComponentValueType | valueType | The option's value type. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<UiComponentInteractionType> | The allowed interaction types, in preference order (first is the default fallback). |
IsInteractionTypeAllowed(UiComponentValueType, UiComponentInteractionType)
Determines whether the given interaction type is valid for the specified value type.
Declaration
public static bool IsInteractionTypeAllowed(UiComponentValueType valueType, UiComponentInteractionType interactionType)
Parameters
| Type | Name | Description |
|---|---|---|
| UiComponentValueType | valueType | The option's value type. |
| UiComponentInteractionType | interactionType | The interaction type to check. |
Returns
| Type | Description |
|---|---|
| bool | True when the pairing is valid. |
ValidateOption(UiOption, string, IReadOnlyDictionary<string, GameSettingsValueType>, IReadOnlyDictionary<string, string>, IReadOnlyDictionary<string, string>, IReadOnlyCollection<string>)
Validates a single option's serialized bindings: interaction-type validity, and (depending on ValueType) its action guid, transition target, or GameSettings id/guid consistency.
Declaration
public static List<string> ValidateOption(UiOption option, string menuId, IReadOnlyDictionary<string, GameSettingsValueType> gameSettingsById, IReadOnlyDictionary<string, string> gameSettingIdsByGuid, IReadOnlyDictionary<string, string> actionIdsByGuid, IReadOnlyCollection<string> menuIds)
Parameters
| Type | Name | Description |
|---|---|---|
| UiOption | option | The option to validate. |
| string | menuId | The owning menu/view id (used to flag unmigrated generated placeholder ids). |
| IReadOnlyDictionary<string, GameSettingsValueType> | gameSettingsById | Known GameSettings value types keyed by asset id. |
| IReadOnlyDictionary<string, string> | gameSettingIdsByGuid | Known GameSettings asset ids keyed by guid. |
| IReadOnlyDictionary<string, string> | actionIdsByGuid | Known action asset ids keyed by guid. |
| IReadOnlyCollection<string> | menuIds | Known top-level menu/view ids (valid transition targets). |
Returns
| Type | Description |
|---|---|
| List<string> | Human-readable issue descriptions; empty when the option is valid. |