menu_bookDocumentation

Custom Editors

calendar_today May 3, 2026 schedule ~1 min read person patrickjr verified 50

Custom Editors

Create custom editor widgets for your classes, structs, and assets.

ControlWidget (Property Editor)

Create custom property editors using [CustomEditor]:

CSHARP
public class MyClass
{
    public Color Color { get; set; }
    public string Name { get; set; }
}

[CustomEditor(typeof(MyClass))]
public class MyCustomControlWidget : ControlObjectWidget
{
    public override bool SupportsMultiEdit => false;

    public MyCustomControlWidget(SerializedProperty property) : base(property)
    {
        Layout = Layout.Row();
        Layout.Spacing = 2;

        // Get properties
        SerializedObject.TryGetProperty(nameof(MyClass.Color), out var color);
        SerializedObject.TryGetProperty(nameof(MyClass.Name), out var name);

        // Add controls
        Layout.Add(Create(color));
        Layout.Add(Create(name));
    }

    protected override void OnPaint()
    {
        // Empty to prevent default background
    }
}

Attribute-Specific Editors

Create editor only for properties with specific attributes:

CSHARP
[CustomEditor(typeof(string), WithAllAttributes = new[] { typeof(PasswordAttribute) })]
public class PasswordEditor : ControlWidget { ... }

InspectorWidget (Full Inspector)

Replace entire inspector for assets or tools:

CSHARP
[CanEdit("asset:char")] // For .char assets
public class CharacterInspector : Widget, IAssetInspector
{
    CharacterResource Character;
    ControlSheet MainSheet;

    public CharacterInspector(Widget parent) : base(parent)
    {
        // Build custom UI
    }

    public void SetAsset(Asset asset)
    {
        // Load and display asset
    }
}

Key Classes

ClassPurpose
ControlWidgetSingle property editor
ControlObjectWidgetObject with multiple properties
InspectorWidgetFull inspector replacement
ControlSheetAutomatic form layout
Was this helpful?