Class UnityUiViewModel
Base Unity UI view model providing reactive properties and game settings management.
Serves as the foundation for UI view models with showing/hiding state management and settings lookup functionality.
Implements
Inherited Members
Namespace: Serenity.Ui.InterfaceAdapters.ViewModels
Assembly: Serenity.UnityUi.InterfaceAdapters.dll
Syntax
public class UnityUiViewModel : IViewModel
Constructors
UnityUiViewModel(string)
Initializes a new Unity UI view model with the specified identifier.
Sets up the reactive showing state property with a default value of true.
Declaration
public UnityUiViewModel(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | The unique identifier for the view model |
Fields
_id
Declaration
protected string _id
Field Value
| Type | Description |
|---|---|
| string |
_isShowing
Declaration
protected ReactiveProperty<bool> _isShowing
Field Value
| Type | Description |
|---|---|
| ReactiveProperty<bool> |
Methods
GetGameSettingsById(string, GameSettingsEntity[])
Retrieves a game settings object by its identifier from an array of settings.
Performs a linear search through the settings array to find a matching ID.
Declaration
public GameSettingsEntity GetGameSettingsById(string id, GameSettingsEntity[] gameSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | The identifier of the game setting to find |
| GameSettingsEntity[] | gameSettings | The array of game settings to search through |
Returns
| Type | Description |
|---|---|
| GameSettingsEntity | The matching game settings object, or null if not found |
GetId()
Gets the unique identifier of the view model.
Provides access to the view model's identification string for external references.
Declaration
public string GetId()
Returns
| Type | Description |
|---|---|
| string | The view model's identifier |
GetIsShowing()
Gets the reactive property indicating whether the view model is currently showing.
Declaration
public ReactiveProperty<bool> GetIsShowing()
Returns
| Type | Description |
|---|---|
| ReactiveProperty<bool> | A reactive property representing the showing state. |
Hide()
Hides the UI view model by setting the showing state to false.
Updates the reactive property to trigger view visibility changes.
Declaration
public void Hide()
SetId(string)
Overrides the routing identifier after construction. Used when the same menu definition is hosted as multiple independent composite instances: each instance's view model carries a globally-unique routing id (the composite host path + definition id) so the presenter routes its show/hide separately, while the view keeps the definition id for composite child addressing.
Declaration
public void SetId(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | The routing identifier to assign. |
Remarks
Safe to call after construction because the id is read via GetId() (not a reactive property) and this is only invoked before the view binds its visibility subscription.
Show()
Shows the UI view model by setting the showing state to true.
Updates the reactive property to trigger view visibility changes.
Declaration
public void Show()