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.

Constructor

csharp
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 )
NameTypeDescription
parentGameObjectParent GameObject used to control lifecycle of the UIView.
parentElementVisualElementThe VisualElement that serves as the parent for this UIView.
startVisibilityUIStartVisibilityThe UIStartVisibility enum defines the possible initial visibility states of the parentElement.
focusElementVisualElementThe VisualElement element to focus whenever UIView becomes visible.
fadeDurationfloatSpecifies the duration of the fade transition, in seconds.
easingModeEasingModeDefines the easing effect applied during fade transitions.
disableOtherViewsOnFadeInboolDisable 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.
debugboolLogs fade transitions, enable/disable events, and UI Actions.

Public Properties

NameTypeDescription
ParentGameObjectParent GameObject used to control lifecycle of the UIView.
ParentElementVisualElementThe VisualElement that serves as the parent for this UIView.
LunaUIManagerLunaUIManagerLunaUIManager 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.
FadeFadeUIElementManage fade transitions of the UIView.
IsEnabledbooltodo
easingModeEasingModeDefines the easing effect applied during fade transitions.
DisableOtherViewsOnFadeInboolDisable 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.

Public Methods

AddAction

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.

csharp
public void AddAction(IUIViewAction action, bool activate = true)
NameTypeDescription
actionIUIViewActionAction to add to the UIView.
activateboolActivates 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.

Example

Register an action that returns to the previous screen when the Escape key is pressed.

csharp
myUIView.AddAction(new UIViewActionEscape(ReturnToPreviousScreen));

Learn more at UI Actions.

See Example: Multi Page UI which demonstrates usage of UIViewActionEscape.

AddChild

csharp
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.

Lifecycle Management

UIView implements IDisposable and manages its lifecycle through automatic registration with the global registry.

Automatic Registration

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.

Automatic Unregistration

Unregistration happens automatically when the parent GameObject is destroyed via UIViewReference.OnDestroy(). You typically don't need to manually unregister UIViews.

Manual Disposal

If you need to manually dispose of a UIView (e.g., when it doesn't have a GameObject lifecycle), you can call Dispose():

csharp
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)

Light
Dark

Font Family

DM Sans

Wix

Inclusive Sans

AR One Sans

Direction

LTR
RTL