The UIView is the base class responsible for managing the lifecycle and visibility of an UI Element. It provides control over UI visibility states, fade animations, and allows for custom actions during these transitions.
public UIView(
GameObject parent,
VisualElement parentElement,
UIStartVisibility startVisibility = UIStartVisibility.Visible,
VisualElement focusElement = null,
float fadeDuration = 0.5f,
EasingMode easingMode = EasingMode.EaseOutCirc,
bool disableOtherViewsOnFadeIn = false,
bool debug = false
)| Name | Type | Description |
|---|---|---|
| parent | GameObject | Parent GameObject used to control lifecycle of the UIView. |
| parentElement | VisualElement | The VisualElement that serves as the parent for this UIView. |
| startVisibility | UIStartVisibility | The UIStartVisibility enum defines the possible initial visibility states of the parentElement. |
| focusElement | VisualElement | The VisualElement element to focus whenever UIView becomes visible. |
| fadeDuration | float | Specifies the duration of the fade transition, in seconds. |
| easingMode | EasingMode | Defines the easing effect applied during fade transitions. |
| disableOtherViewsOnFadeIn | bool | Disable the interactable elements on other views whenever this view becomes visible. This is particularly useful for UI navigation with keys when opening a modal or screen on top of another view. This will prevent the auto navigation from interacting with the elements behind this view. |
| debug | bool | Logs fade transitions, enable/disable events, and UI Actions. |
| Name | Type | Description |
|---|---|---|
| Parent | GameObject | Parent GameObject used to control lifecycle of the UIView. |
| ParentElement | VisualElement | The VisualElement that serves as the parent for this UIView. |
| LunaUIManager | LunaUIManager | LunaUIManager tracks interactable visual elements, enabling mass activation or deactivation within a UIView. You can also set a blocking element to prevent interaction with other elements until it is clicked. |
| Fade | FadeUIElement | Manage fade transitions of the UIView. |
| IsEnabled | bool | todo |
| easingMode | EasingMode | Defines the easing effect applied during fade transitions. |
| DisableOtherViewsOnFadeIn | bool | Disable the interactable elements on other views whenever this view becomes visible. This is particularly useful for UI navigation with keys when opening a modal or screen on top of another view. This will prevent the auto navigation from interacting with the elements behind this view. |
Adds a new action to the view's action list.
If the view is currently faded in, the action's OnFadeIn method will be triggered immediately.
The action will be automatically enabled or disabled in sync with the view's fade-in or fade-out state.
public void AddAction(IUIViewAction action, bool activate = true)| Name | Type | Description |
|---|---|---|
| action | IUIViewAction | Action to add to the UIView. |
| activate | bool | Activates the Action immediately if the UIView is currently enabled. If the UIView is not enabled, the Action is not triggered even if this is true. |
Register an action that returns to the previous screen when the Escape key is pressed.
myUIView.AddAction(new UIViewActionEscape(ReturnToPreviousScreen));Learn more at UI Actions.
See Example: Multi Page UI which demonstrates usage of UIViewActionEscape.
public void AddChild(UIView child)When you have nested UIViews with UI Actions, you might need to register their parent-child relationships.
Whenever a parent UIView is enabled or disabled, it will trigger the UI Actions of its children.
The Example: Multi Page UI also demonstrates parent-child relationships.
UIView implements IDisposable and manages its lifecycle through automatic registration with the global registry.
When a UIView is constructed, it automatically registers itself with the global registry managed by LunaUIManager. This allows the system to track all UIViews in the scene and apply global USS classes to them when needed.
Unregistration happens automatically when the parent GameObject is destroyed via UIViewReference.OnDestroy(). You typically don't need to manually unregister UIViews.
If you need to manually dispose of a UIView (e.g., when it doesn't have a GameObject lifecycle), you can call Dispose():
myUIView.Dispose();This will clean up the UIView and unregister it from the global registry.
Settings
Theme
Light
Contrast
Material
Dark
Dim
Material Dark
System
Sidebar(Light & Contrast only)
Font Family
DM Sans
Wix
Inclusive Sans
AR One Sans
Direction