ParagonVisualElementDrawer
Abstract base class for property drawers that use UI Toolkit for rendering instead of pure IMGUI. Extends ParagonDrawer<TProperty> and bridges the Odin Inspector IMGUI pipeline to a UI Toolkit VisualElement tree via OdinImGuiElement. Contains a private nested ParagonPropertyElement that delegates its OnCreateGUI() back to the drawer.
Definition
Namespace: Paragon.Editor Assembly: Paragon.Editor.dll
public abstract class ParagonVisualElementDrawer<TProperty> : ParagonDrawer<TProperty>Inheritance: OdinValueDrawer<TProperty> → ParagonDrawer<TProperty> → ParagonVisualElementDrawer<TProperty>
Remarks
This drawer works by embedding a UI Toolkit VisualElement tree inside Odin's IMGUI rendering pipeline:
Initialize()— Creates aParagonPropertyElement(a private ParagonVisualElement subclass) that wraps the drawer. Adds anIMGUIContainerforOnInspectorGUI(). Wraps everything in anOdinImGuiElementfor Odin IMGUI compatibility.DrawPropertyLayout()(sealed) — Null-checks the property value, then callsImguiElementUtils.EmbedVisualElementAndDrawItHere()to render the UI Toolkit tree inside the IMGUI context.ParagonPropertyElement.OnCreateGUI()— Delegates to the drawer'sOnCreateGUI(), which is where subclasses build their visual tree.ParagonPropertyElement.GetTemplateAsset()— Reads the[UxmlTemplate]attribute from the drawer class (not the element class), allowing drawers to bind UXML templates.
Quick Lookup
Build UI
Override OnCreateGUI() — add elements via Add(child)
Add IMGUI content
Override OnInspectorGUI()
Query elements
Q("name") or Q<Button>("name")
Bind a UXML template
Add [UxmlTemplate("Name")] to the drawer class
Access property value
Use target (inherited from ParagonDrawer<T>)
Control drawer priority
Add [DrawerPriority(DrawerPriorityLevel.SuperPriority)]
Properties
name
string
public
The root element's name (set to typeof(TProperty).Name)
propertyElement
VisualElement
protected
The inner ParagonPropertyElement — add children here via Add()
Methods
OnCreateGUI
Abstract callback to build the visual tree. Called by the inner ParagonPropertyElement during its creation lifecycle. Use Add() and Q() to construct and query the UI.
OnInspectorGUI
Virtual callback for per-frame IMGUI content rendered inside the embedded IMGUIContainer.
DrawPropertyLayout
Sealed. Null-checks ValueEntry.SmartValue and embeds the UI Toolkit element via Odin's IMGUI bridge. Cannot be overridden.
Add
Adds a child element to the propertyElement.
Q
Queries the propertyElement for children by name.
Extension Points
Required Overrides
OnCreateGUI()
Build the visual tree — add elements, query template children
Optional Overrides
OnInspectorGUI()
Per-frame IMGUI content alongside the visual tree
Implementation Requirements
When subclassing, you MUST:
Override
OnCreateGUI()— this is abstractUse
Add()to add children (adds topropertyElement, not root)Use
Q()to query children (queriespropertyElement, not root)
You SHOULD:
Add
[DrawerPriority(DrawerPriorityLevel.SuperPriority)]to ensure priority over default drawersAdd
[UxmlTemplate("TemplateName")]to bind a UXML template (template is resolved from the drawer class, not the property element)
You MUST NOT:
Override
DrawPropertyLayout()— it is sealedAdd children directly to
rootVisualElement— useAdd()which targetspropertyElement
Operators
implicit operator VisualElement
Converts the drawer to its root VisualElement
Common Pitfalls
Null values are silently skipped. DrawPropertyLayout() returns early if ValueEntry.SmartValue == null. Your OnCreateGUI() and OnInspectorGUI() will never be called for null property values. This means no "create" or "assign" UI is shown by default.
Add() and Q() target propertyElement, not the root. The drawer's element hierarchy is rootVisualElement → propertyElement → your children + IMGUIContainer. Direct rootVisualElement access is not exposed to subclasses.
UXML template resolves from the drawer class. The inner ParagonPropertyElement overrides GetTemplateAsset() to look for [UxmlTemplate] on the drawer class (e.g., ParagonSubsystemDrawer), not on ParagonPropertyElement itself.
Examples
UI Toolkit Property Drawer with Template
Minimal Programmatic Drawer
See Also
ParagonDrawer<TProperty> — IMGUI-only base drawer (parent class)
ParagonVisualElement — base visual element (used internally as
ParagonPropertyElement)ParagonEditor — base editor with similar UXML + IMGUI pattern
Objects — editor objects overview
Last updated