UI Actions are a core feature of the UIView system that allow developers to link custom behaviors to the view's visibility transitions (fade in/out). These actions implement the IUIViewAction interface and are executed automatically whenever the UIView's visibility changes.

The IUIViewAction interface

csharp
namespace CupkekGames.Luna { public interface IUIViewAction { void OnFadeInStart(); void OnFadeOut(); } }
MemberWhen it fires
OnFadeInStart()The view starts becoming visible — fade-in begins, the view is born visible via ApplyStartVisibility(true), or the action is added with activate: true while the view is already visible.
OnFadeOut()The view finishes hiding — fade-out completes (not when it starts), or the view is born hidden via ApplyStartVisibility(false).

The asymmetry is deliberate: an action registers at fade-in start so its behavior (an Esc handler, a paused timescale) is live while the entrance animation is still playing, and it releases only at fade-out completion so the behavior stays active until the view is actually gone.

Actions also fire through parent-child propagation: when a parent UIView registered via AddChild fades in, the actions of its currently-visible children fire in sync (on parent fade-out, only currently-hidden children get their OnFadeOut re-fired as cleanup — a visible child's actions are released by the child's own fade-out, not the parent's). See Example: Multi Page UI — Nested UIViews for why this matters.

This provides a simple, event-driven way to manage UI behavior that needs to sync with the view's state.

Writing a custom action

Any class implementing the two members can be registered with UIView.AddAction. For example, an action that pauses the game while a menu is open:

csharp
using CupkekGames.Luna; using UnityEngine; /// <summary>Pauses gameplay while the owning view is visible.</summary> public class UIViewActionPauseTime : IUIViewAction { public void OnFadeInStart() { Time.timeScale = 0f; // fade-in begins — pause } public void OnFadeOut() { Time.timeScale = 1f; // fade-out finished — resume } }

Register it on the view (from a UIViewComponent, wait for the UI to load first):

csharp
myView.WhenUILoaded(() => { myView.UIView.AddAction(new UIViewActionPauseTime()); });

AddAction(action, activate: true) triggers OnFadeInStart() immediately when the view is already visible at registration time — pass activate: false to defer until the next real fade-in (the nested-views example shows when you need this).

Default Actions

UIViewActionEscape

This class allows you to push and pop a custom action(System.Action) into the InputEscapeManager in sync with the visibility of an UIView. On OnFadeInStart it pushes the callback onto the escape stack under a stable key; on OnFadeOut it pops it again (without executing), so Esc means "your callback" exactly while the view is visible.

Constructor

csharp
public UIViewActionEscape(Action onEscape = null, bool debug = false)

Example

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

See Example: Multi Page UI for more detailed example.

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