Class UnityMenuViewModel
Unity-specific view model for menu system with reactive properties for UI interaction.
Namespace: Serenity.Menu.InterfaceAdapters.ViewModels
Assembly: Serenity.UnityMenu.InterfaceAdapters.dll
Syntax
public class UnityMenuViewModel : UnityUiViewModel
Constructors
UnityMenuViewModel(string, UiOption[])
Initializes a new Unity menu view model with the specified options.
Declaration
public UnityMenuViewModel(string id, UiOption[] options)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | The unique identifier for the menu. |
| UiOption[] | options | The array of UI options available in the menu. |
Fields
_isCanceling
Declaration
protected ReactiveProperty<bool> _isCanceling
Field Value
| Type | Description |
|---|---|
| ReactiveProperty<bool> | Reactive property for the cancellation state of the menu. |
_isSubmitting
Declaration
protected ReactiveProperty<bool> _isSubmitting
Field Value
| Type | Description |
|---|---|
| ReactiveProperty<bool> | Reactive property for the submission state of the menu. |
_options
Declaration
protected ReactiveProperty<UiOption[]> _options
Field Value
| Type | Description |
|---|---|
| ReactiveProperty<UiOption[]> | Reactive property for the array of options available in the menu. |
_selectedOptionIndex
Declaration
protected ReactiveProperty<int> _selectedOptionIndex
Field Value
| Type | Description |
|---|---|
| ReactiveProperty<int> | Reactive property for the currently selected option index in the menu. |
Methods
Cancel()
Triggers cancellation of the current menu interaction.
Declaration
public void Cancel()
ChangeOptionValue(UiOptionValue, string)
Changes the value of a specific menu option and updates the menu state.
Declaration
public void ChangeOptionValue(UiOptionValue value, string optionId)
Parameters
| Type | Name | Description |
|---|---|---|
| UiOptionValue | value | The new value to assign to the option. |
| string | optionId | The unique identifier of the option to modify. |
GetIsCanceling()
Gets the reactive property indicating whether the menu is in a canceling state.
Declaration
public ReactiveProperty<bool> GetIsCanceling()
Returns
| Type | Description |
|---|---|
| ReactiveProperty<bool> | A reactive property indicating cancellation status. |
GetIsSubmitting()
Gets the reactive property indicating whether the menu is in a submitting state.
Declaration
public ReactiveProperty<bool> GetIsSubmitting()
Returns
| Type | Description |
|---|---|
| ReactiveProperty<bool> | A reactive property indicating submission status. |
GetOptionByIndex(int)
Gets a menu option by its index position.
Declaration
public UiOption GetOptionByIndex(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the option to retrieve. |
Returns
| Type | Description |
|---|---|
| UiOption | The UI option at the specified index. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when the index is outside the valid range of options. |
GetOptions()
Gets the reactive property containing all menu options.
Declaration
public ReactiveProperty<UiOption[]> GetOptions()
Returns
| Type | Description |
|---|---|
| ReactiveProperty<UiOption[]> | A reactive property containing the array of UI options. |
GetSelectedOption()
Gets the currently selected menu option.
Declaration
public UiOption GetSelectedOption()
Returns
| Type | Description |
|---|---|
| UiOption | The currently selected UI option. |
GetSelectedOptionIndex()
Gets the reactive property for the currently selected option index.
Declaration
public ReactiveProperty<int> GetSelectedOptionIndex()
Returns
| Type | Description |
|---|---|
| ReactiveProperty<int> | A reactive property containing the selected option index. |
SelectOption(int)
Selects a menu option at the specified index.
Declaration
public void SelectOption(int optionIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | optionIndex | The index of the option to select. |
SubmitOption()
Triggers submission of the currently selected menu option.
Declaration
public void SubmitOption()