UCanvasPanel
Inherits: UObjectBase › UObjectBaseUtility › UObject › UVisual › UWidget › UPanelWidget › UCanvasPanel
#include "Components/CanvasPanel.h" Description
A panel that positions children at arbitrary locations using anchor-based layout with Z-ordering support. Best for top-level HUD layouts where children need precise absolute or anchored positioning.
Caveats & Gotchas
- • Position, size, and anchor settings live on UCanvasPanelSlot, not on the panel. Retrieve the slot from the return value of AddChildToCanvas().
- • Canvas panels do not reflow when siblings are added or removed — children stay at their absolute positions. Prefer UVerticalBox or UHorizontalBox for lists that should reflow.
- • Deeply nested canvas panels add layout overhead. Use flow-based panels internally and reserve canvas for the outermost HUD layout.
Example
Add a widget and set its slot position C++
UCanvasPanelSlot* Slot = MyCanvas->AddChildToCanvas(MyWidget);
if (Slot)
{
Slot->SetPosition(FVector2D(100.f, 200.f));
Slot->SetSize(FVector2D(300.f, 50.f));
Slot->SetAnchors(FAnchors(0.f, 0.f));
} See Also
Version History
Introduced in: 4.5
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?