Vixen
02b45cc4
csharp
public sealed class CustomInspectorAttribute

Marks a static method as the inspector for a type.

Read the guide page for this →

As a annotation

Valid on
Method

Remarks

Doc 36 § D3. The method is what Build takes: it is handed the panel's body and the EditTarget, and fills the first from the second.

[CustomInspector(typeof(TerrainComponent))] public static void Draw(UiElement body, EditTarget target) { … }

⚠ A static method rather than a class, unlike Unity's [CustomEditor]. Unity's attribute goes on an Editor subclass because the thing it overrides is a virtual method on a base with state. Ours has no base and no state — a custom inspector *is* an Action<UiElement, EditTarget>, and a class whose only job is to hold one method would be ceremony that buys nothing. It also matches [EditorMenu], which is the other thing an author writes on a loose static method.

⚠ Read by a scan of the assembly that declared it, and only for a plugin or a project script. ADR-002 forbids assembly scanning as a way of building the editor — a scan reads metadata a trimmed publish has deleted and makes start-up cost grow with what is installed. Neither applies to one discrete assembly the editor has just loaded or just compiled, and the plugin loader already enumerates a plugin's types to find its entry point. In-tree code registers a CustomInspector directly.

Fields and properties (2)

  • public Type Target

    The type it draws.

  • public int Order

    Which of two inspectors for one type wins; the higher one.

Methods (1)

  • public CustomInspectorAttribute(Type target)

    Marks a static method as the inspector for a type.

Used by (1)

  • DeclaredContributionsVixen.Editor.App