Elements

Window

An abstract draggable, resizable window component. Subclass Window and implement RenderContent() to define the body. Windows are created via WindowManager.GetWindow<T>() and support edge snapping (8px), resize-buddy propagation (adjacent docked windows resize together when you drag the seam), z-order management via BringToFront, anchored cascade placement, and per-window placement persistence to PlayerPrefs.

Window extends Component (not Group) because it owns reactive state, lifecycle hooks, and a complex render tree built around an abstract RenderContent() hook.

Constructor

public class InventoryWindow : Window
{
    public InventoryWindow()
    {
        Title.Value = "Inventory";
        StartingSize = new Vector2(320, 240);
        StartingPosition = WindowStartPosition.TopLeft;
        MinSize = new Vector2(200, 120);
    }

    protected override IElement RenderContent()
    {
        return new VerticalGroup(
            new Label("Inventory items go here").ClassName("h3")
        ).Padding(8);
    }
}

Open it via the manager:

windowManager.GetWindow<InventoryWindow>("primary");

Examples

Basic Window

A minimal window with text content:

public class HelloWindow : Window
{
    public HelloWindow()
    {
        Title.Value = "Hello";
        StartingSize = new Vector2(280, 160);
    }

    protected override IElement RenderContent() =>
        new Label("Hello, World!").Padding(16);
}

Custom Title Bar

Override RenderTitleBarChildren() to add controls. The close button is added automatically — return only the additional children:

public class ToolWindow : Window
{
    protected override IElement[] RenderTitleBarChildren()
    {
        return new IElement[]
        {
            new Image("Icons/tool"),
            new Label(Title).ClassName("elements-window-title"),
            new Button(new Label("?"))
                .ClassName("elements-window-close-button")
                .OnClick(_ => OpenHelp())
        };
    }

    protected override IElement RenderContent() => new Label("Tool content");
}

Multiple Windows + Manager

The manager owns the lifecycle:

var manager = new WindowManager();
parent.Add(manager.BuildVisualElement());

manager.GetWindow<InventoryWindow>("primary");
manager.GetWindow<MapWindow>("primary");
manager.GetWindow<ChatWindow>("guild");

Reactive Title and Persistence Opt-Out

public class EditorWindow : Window
{
    public EditorWindow(ReactiveProperty<string> documentName)
    {
        OptOutOfPlacementMemory = true;          // always opens at StartingPosition
        StartingPosition = WindowStartPosition.Center;
        BindTitle(documentName.Select(n => $"Editing — {n}"));
    }

    protected override IElement RenderContent() => new Label("Document body");
}

Fluent Configuration

public class QuickWindow : Window
{
    public QuickWindow()
    {
        WithStartingSize(420, 280)
            .WithMinSize(240, 160)
            .StartAt(WindowStartPosition.TopRight)
            .WithoutPlacementMemory();
    }

    protected override IElement RenderContent() => new Label("Quick");
}

Properties

PropTypeDefault
Title?
ReactiveProperty<string>
"Window"
Position?
ReactiveProperty<Vector2>
(50, 50)
Size?
ReactiveProperty<Vector2>
(320, 200)
MinSize?
Vector2
(160, 80)
MaxSize?
Vector2
(∞, ∞)
StartingSize?
Vector2
(320, 200)
StartingPosition?
WindowStartPosition
Center
OptOutOfPlacementMemory?
bool
false

Methods

PropTypeDefault
BringToFront?
() => void
-
Close?
() => void
-
BindTitle?
(Observable<string>) => Window
-
WithMinSize?
(float x, float y) => Window
-
WithMaxSize?
(float x, float y) => Window
-
WithStartingSize?
(float x, float y) => Window
-
StartAt?
(WindowStartPosition) => Window
-
WithoutPlacementMemory?
() => Window
-
RenderContent?
abstract () => IElement
-
RenderTitleBarChildren?
virtual () => IElement[]
-

CSS Classes

  • .elements-window — Window root container
  • .elements-window-content — Wrapper around the user's RenderContent() output
  • .elements-window-title-bar — Title bar HorizontalGroup
  • .elements-window-title — Title Label
  • .elements-window-close-button — Close Button
  • .elements-window-resize-handle — Base class on all 8 resize handles
  • .elements-window-resize-l / -r / -t / -b — Edge handles
  • .elements-window-resize-tl / -tr / -bl / -br — Corner handles
  • .elements-window-hover-l / -r / -t / -b / -tl / -tr / -bl / -br — Applied to the window root while a resize handle is hovered or active; drives the highlighted edge.

WindowStartPosition Enum

PropTypeDefault
Center?
WindowStartPosition
-
TopLeft?
WindowStartPosition
-
TopRight?
WindowStartPosition
-
BottomLeft?
WindowStartPosition
-
BottomRight?
WindowStartPosition
-

Window extends Component.