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, 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.
focusElementVisualElementThe VisualElement to focus whenever the UIView becomes visible. When null, no element is focused on fade-in. (UIViewComponent passes the view root when its Focus Name field is empty — the fallback happens there, not in UIView.)
fadeDurationfloatSpecifies the duration of the fade transition, in seconds.
easingModeEasingModeDefines the easing effect applied during fade transitions.
disableOtherViewsOnFadeInboolBlocks input on the elements of 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. See Input blocking.
debugboolLogs fade transitions, enable/disable events, and UI Actions.

There is no start-visibility parameter. The view's born state is applied separately with ApplyStartVisibilityUIViewComponent calls it right after construction (visible for node-less views; the node's StartVisible for navigation destinations).

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.
IsVisibleboolReturns true if the UIView is currently visible (faded in).
FocusElementVisualElementElement that receives keyboard focus when this view fades in. Read-only — set at construction; null (no focus) when none was given. UIViewComponent passes the view root for an empty Focus Name.
PushArgsobjectPer-push args set by the navigation system right before fade-in. null when the view was activated without args. See Push args.
DisableOtherViewsOnFadeInboolBlocks input on the elements of 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. See Input blocking.

Input blocking

When DisableOtherViewsOnFadeIn is set, fading this view in calls LunaUIManager.SetInputBlockedAllPages with every other registered page. Blocked elements get pickingMode = Ignore and focusable = false — they ignore pointer events and are skipped by keyboard navigation, but their visual styling is untouched. Unlike SetEnabled(false), no :disabled USS rules fire, so nothing behind a modal visibly greys out during the fade. Each element's original pickingMode is snapshotted at block time and restored exactly when this view fades out.

Public Methods

ApplyStartVisibility

Apply the configured born-state visibility. Call once, right after construction (UIViewComponent does this at the first PanelRenderer reload).

csharp
public void ApplyStartVisibility(bool startVisible)

This is a pure snap — no animations, no FadeEventTrigger transitions fire. true snaps to opacity: 1 / display: flex and fires the enable lifecycle; false snaps to opacity: 0 / display: none and fires the disable lifecycle. Subsequent visibility changes go through Fade.FadeIn / Fade.FadeOut (or the component wrappers Show / Hide); this method is not re-entrant.

SetVisualState

Instant style write — sets opacity and display to the visible or hidden steady-state without going through the fade transition pipeline.

csharp
public void SetVisualState(bool visible)

AddAction

Adds a new action to the view's action list.

If the view is currently faded in, the action's OnFadeInStart 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.

SetParentElement

Swap the cached parent VisualElement when the panel delivers a fresh tree — driven by UIViewComponent on subsequent PanelRenderer reloads (property changes, re-enables). Propagates the new reference to the FadeUIElement so subsequent FadeIn/FadeOut and transition lookups resolve against the live panel. No-op when the element is unchanged.

csharp
public void SetParentElement(VisualElement parentElement)

ClearTransitions

Removes all transition entries from the UIView. In-flight plays are not cancelled.

csharp
public void ClearTransitions()

Push args

When a view is opened through navigation, the nav system hands it a per-push args object immediately before fade-in:

csharp
public object PushArgs { get; } // null when no args were set public T GetArgs<T>() where T : class // typed read; null on mismatch public void SetPushArgs(object args) // called by nav; re-push overwrites stale args

SetPushArgs may also legitimately be called by storybook/test code that wants to seed a scene-active view without going through the nav stack — call it before the view's first fade-in so OnFadeInStart handlers read the right value.

State reset

csharp
public event Action<object> StateResetRequested; public void RequestStateReset(object args);

StateResetRequested fires when this view should clear and re-seed its internal state — typically before a reopen for views whose nav destination authors ResetStateOnReopen = true. The argument is the args object being passed for this push. RequestStateReset invokes the event; the nav system calls it on reopen. UIViewComponent subscribes automatically and dispatches to its OnStateReset(object args) virtual, which is the consumer extension point.

Fade-in semantics

Fade.FadeIn() fires OnFadeInStart on the first call of a visible session even when the element is already at full opacity — the born-visible reveal case, where ApplyStartVisibility(true) snapped the view visible during boot and the first real fade-in still needs to run authored transitions and enable UI Actions. A second FadeIn() on the same still-visible element no-ops instead of re-running every transition. The guard resets when the element completes a fade-out.

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 unsubscribes the fade event handlers, stops any in-flight fade, releases the page registration (restoring any input-block this view held on other views), and unregisters from the global registry. UIViewComponent calls it from its OnDestroy.

Transition Animations

UIViews can automatically play Transition Animations when fading in or out. This enables rich entrance/exit animations without manual event wiring.

FadeEventTrigger

The FadeEventTrigger enum defines when an animation should play:

ValueDescription
NoneNo automatic trigger
FadeInStartWhen fade-in begins
FadeInCompleteWhen fade-in finishes
FadeOutStartWhen fade-out begins
FadeOutCompleteWhen fade-out finishes

Adding Transitions

Use AddTransition() to register animations. Entries with no Animation or no Target are rejected (they would be silent no-ops):

csharp
// Add a single transition — target the modal-content child by name. myUIView.AddTransition(new UIViewTransitionEntry { Animation = popBounceInAsset, // TransitionSequenceAsset Trigger = FadeEventTrigger.FadeInStart, Target = new ElementSelector { Name = "modal-content" } }); // Add multiple transitions at once — the default Target is the view root. myUIView.AddTransitions(new[] { new UIViewTransitionEntry { Animation = fadeInAsset, Trigger = FadeEventTrigger.FadeInStart }, new UIViewTransitionEntry { Animation = slideOutAsset, Trigger = FadeEventTrigger.FadeOutStart } });

UIViewTransitionEntry

PropertyTypeDescription
AnimationTransitionSequenceAssetThe animation preset to play on each matched element
TargetElementSelectorWhich element(s) to play on. Default = the UIView's parent element. See ElementSelector below
TriggerFadeEventTriggerWhich fade event triggers the animation
StepMslongDelay between successive matches in milliseconds. 0 = simultaneous. Non-zero gives the DOM-order stagger pass

ElementSelector

ElementSelector resolves elements in two steps: Name/ClassName (AND-ed; empty = no constraint) pick anchor element(s) under the view root; ScopeValue says what to return relative to each anchor; ElementTypeValue then filters the returned set to that UITK type (Any = no constraint):

ScopeValueReturns
Self (default)The anchor element itself. With no filters set, that's the view root
ChildrenThe anchor's direct children (the CSS X > * pattern)
DescendantsEvery descendant of the anchor (the CSS X * pattern)

Common shapes:

csharp
new ElementSelector() // the view root new ElementSelector { Name = "content-panel" } // the element named content-panel new ElementSelector { ClassName = "stagger" } // every element tagged .stagger new ElementSelector { Name = "list", // direct children of #list ScopeValue = ElementSelector.Scope.Children }

Pairing a ClassName selector with a non-zero StepMs gives the canonical DOM-order entry bounce.

Example: Modal with Entrance Animation

csharp
public class ModalView : UIView { public ModalView(GameObject parent, VisualElement root, TransitionSequenceAsset popIn) : base(parent, root) { // Play bounce animation on the content panel when modal fades in AddTransition(new UIViewTransitionEntry { Animation = popIn, Trigger = FadeEventTrigger.FadeInStart, Target = new ElementSelector { Name = "content-panel" } }); } }

Using TransitionAnimator Component

For Inspector-based setup, you can use the TransitionAnimator component with a UIViewComponent reference:

  1. Add TransitionAnimator to the same GameObject
  2. Reference the UIViewComponent
  3. Set Fade Trigger to the desired event
  4. Add your animation nodes

The TransitionAnimator will automatically subscribe to the UIView's fade events.

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