ChoicePopupController is a UIViewComponent that renders an N-button modal — Yes/No, Save/Discard/Cancel, or any custom set. Buttons are built dynamically from a serialized ChoicePopupChoice[] list (text + color), and the controller fires OnButtonClick(int index) so callers can handle each choice.

The popup expects three named elements inside a UIDocument:
| Element | Name |
|---|---|
Label | Header |
Label | Body |
VisualElement | ButtonContainer |
The controller fills ButtonContainer with one Button per ChoicePopupChoice on fade-in.
Add ChoicePopupController to the GameObject. In the inspector:
_textHeader / _textBody — initial labels._choices — the button list (text + color name)._buttonClasses — extra USS classes applied to every generated button (e.g. "btn-xl").
[SerializeField] ChoicePopupController _popup;
void OnDeleteClicked()
{
_popup.TextHeader = "Delete save?";
_popup.TextBody = "This cannot be undone.";
_popup.Choices = new[]
{
new ChoicePopupChoice("Delete", "red"),
new ChoicePopupChoice("Cancel", "slate"),
};
_popup.OnButtonClick += OnConfirmDelete;
_popup.UIView.Fade.FadeIn();
}
void OnConfirmDelete(int index)
{
if (index == 0) DeleteSave();
_popup.OnButtonClick -= OnConfirmDelete;
}Use the standard UIView.Fade API (FadeIn, FadeOutThenDestroy) to show/hide.
namespace CupkekGames.Luna;
public class ChoicePopupController : UIViewComponent| Property | Type | Description |
|---|---|---|
Choices | ChoicePopupChoice[] | Button list. Re-assigning rebuilds buttons on next fade-in. |
TextHeader | string | Read/write the header label. |
TextBody | string | Read/write the body label. |
public event Action<int> OnButtonClick;Fires with the index of the clicked choice. After click, all buttons are disabled and the popup fades out.
public ChoicePopupChoice(string text, string color);color is a Luna color-class name ("lime", "red", "slate", etc. — see colors). Applied as a USS class on the button alongside btn.
UIViewActionEscape(Fade.FadeOut) is registered on Awake, so Escape closes the popup with a fade-out.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