Class UnityMenuService
Unity MonoBehaviour implementation of IMenuService that manages menu view display and navigation.
Handles the lifecycle and state management of Unity-based menu views throughout the application.
Namespace: Serenity.Menu.Infrastructure.Services
Assembly: Serenity.UnityMenu.Infrastructure.dll
Syntax
public class UnityMenuService : MonoBehaviour, IMenuService, IService, IFoundationSettings
Constructors
UnityMenuService()
Declaration
public UnityMenuService()
Fields
_logService
Declaration
protected ILogService _logService
Field Value
| Type | Description |
|---|---|
| ILogService | ILogService for logging within the menu service. |
_menuViews
Declaration
protected Dictionary<string, UnityMenuView> _menuViews
Field Value
| Type | Description |
|---|---|
| Dictionary<string, UnityMenuView> | Dictionary of Unity menu views keyed by their identifiers for efficient lookup. |
Properties
Guid
Declaration
public string Guid { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Gets or sets the globally unique identifier for this service. |
Id
Declaration
public string Id { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
LogService
Declaration
public ILogService LogService { get; set; }
Property Value
| Type | Description |
|---|---|
| ILogService |
Methods
DeactivateMenuContext()
Declaration
public void DeactivateMenuContext()
GetCurrentView()
Gets the currently active menu view by checking which view's options wrapper is active.
Returns null if no menu view is currently active.
Declaration
public IViewBase GetCurrentView()
Returns
| Type | Description |
|---|---|
| IViewBase | The currently active IViewBase implementation, or null if none are active. |
InitializeService(Dictionary<string, IViewBase>, IViewBrowserService, string)
Initializes the menu service with the provided menu views.
Validates that all provided views are UnityMenuView instances and stores them for management.
Declaration
public void InitializeService(Dictionary<string, IViewBase> menuViews, IViewBrowserService viewBrowserService, string initMenuId)
Parameters
| Type | Name | Description |
|---|---|---|
| Dictionary<string, IViewBase> | menuViews | Dictionary of menu views keyed by their identifiers. |
| IViewBrowserService | viewBrowserService | Service for managing view navigation and lifecycle operations between menu screens. |
| string | initMenuId | The ID of the initial menu to show when ShowInitialMenu is called. |
Exceptions
| Type | Condition |
|---|---|
| Exception | Thrown when a view is not a UnityMenuView instance. |
ShowInitialMenu()
Shows the initial menu configured during initialization.
This is the menu that should be displayed at startup or when returning from gameplay.
Declaration
public void ShowInitialMenu()
Exceptions
| Type | Condition |
|---|---|
| Exception | Thrown when InitMenuId is not configured or the menu is not found. |
ShowMenu(string)
Shows the menu with the specified identifier by executing its show menu operation.
Activates the requested menu view and makes it visible to the user.
Declaration
public void ShowMenu(string menuId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | menuId | The identifier of the menu to show. |
Exceptions
| Type | Condition |
|---|---|
| Exception | Thrown when the specified menu ID is not found in the service. |