ParagonBehaviourContextMenu
Static editor class that injects a gear icon context menu into the Inspector header of every ParagonBehaviour. Provides quick toggles for enabling/disabling subsystems and debug mode without navigating into component properties.
Definition
Namespace: Paragon.Editor Assembly: Paragon.Editor.dll
[InitializeOnLoad]
public static class ParagonBehaviourContextMenuRemarks
This class uses EditorHeaderItemInjector (a reflection-based utility) to insert a custom UI callback into Unity's internal editor header item pipeline. The injection happens in the static constructor, ensuring it runs automatically when the editor domain loads via [InitializeOnLoad].
The injected callback (OnContextMenuGUI) renders a gear icon button for every ParagonBehaviour target in the Inspector. When clicked, it shows a GenericMenu with:
Use Subsystem — Toggle that creates or destroys the
ParagonSubsystemon the behaviour. Only shown if the behaviour implementsIParagonSubsystem<>. The checkmark reflectsbehaviour.HasSubsystem.Enable Debug — Toggle that enables or disables
DebugEnabledon the behaviour. The checkmark reflectsbehaviour.DebugEnabled.
The menu actions delegate to ParagonBehaviourEditor.EnableSubsystem(), DisableSubsystem(), and SetDebugEnabled().
Quick Lookup
Toggle subsystem on a behaviour
Click gear icon → "Use Subsystem"
Toggle debug mode
Click gear icon → "Enable Debug"
Extend with custom menu items
Not supported — class is static and sealed
Methods
All methods are private. The class exposes no public API — it operates entirely through the injected editor header callback.
OnContextMenuGUI (private)
The injected callback that renders the gear icon and dropdown menu.
buttonRect
Rect
The position for the button in the header
targets
Object[]
The currently selected editor targets
Returns: true if any target was a ParagonBehaviour (indicating the button was rendered).
Common Pitfalls
"Use Subsystem" not appearing The "Use Subsystem" menu item only appears if the behaviour implements IParagonSubsystem<>. Regular ParagonBehaviour subclasses that don't implement this interface will only see "Enable Debug".
See Also
ParagonBehaviourEditor — the editor class whose methods the context menu invokes
ParagonSubsystemDrawer — the drawer that renders the subsystem once enabled
Last updated