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 ParagonBehaviourContextMenu

Remarks

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 ParagonSubsystem on the behaviour. Only shown if the behaviour implements IParagonSubsystem<>. The checkmark reflects behaviour.HasSubsystem.

  • Enable Debug — Toggle that enables or disables DebugEnabled on the behaviour. The checkmark reflects behaviour.DebugEnabled.

The menu actions delegate to ParagonBehaviourEditor.EnableSubsystem(), DisableSubsystem(), and SetDebugEnabled().

Quick Lookup

Goal
How

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.

Parameter
Type
Description

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

circle-exclamation

See Also

Last updated