menu_bookDocumentation
Editor Widgets
Editor Widgets
Build custom editor UI using Widgets (different from in-game Panels).
Creating a Widget
CSHARP
public class ExampleWidget : Widget
{
public ExampleWidget(Widget parent) : base(parent, false)
{
// Column layout with spacing
Layout = Layout.Column();
Layout.Margin = 4;
Layout.Spacing = 4;
// CSS styling (similar to Panels)
SetStyles("background-color: #303445; color: white; font-weight: 600;");
// Add children
Layout.Add(new Label("Press the button:", this));
var btn = Layout.Add(new Button("Click me!", this));
btn.Clicked += () => Log.Info("Clicked!");
}
}Widget as Window
CSHARP
// No parent = root window
var window = new ExampleWidget(null);
window.Show();Widget as Child
CSHARP
// With parent = child widget
var child = new ExampleWidget(parentWidget);
parentWidget.Layout.Add(child);Dockable Widget
CSHARP
[Dock("Editor", "My Tool", "icon_name")]
public class MyDockWidget : Widget
{
// Appears in View menu
// Can be docked/undocked
}Asset Editor Widget
CSHARP
[EditorForAssetType("item")]
public class ItemEditor : Window, IAssetEditor
{
public bool CanOpenMultipleAssets => true;
public void AssetOpen(Asset asset)
{
// Opened from double-click in Asset Browser
}
}Widget vs Panel
| Widget | Panel | |
|---|---|---|
| Use | Editor UI | In-game UI |
| Location | Editor project | Game project |
| Styling | CSS | SCSS |
Common Widgets
Was this helpful?