Marks a static method as a contributor to the graph view's right-click contextual menu. Every time the menu opens, the decorated method is invoked with a GraphMenuContext that exposes the element under the cursor and lets the method append entries via GraphMenuContext.AppendAction.
The decorated method must be static, return void, and take
a single GraphMenuContext parameter. The user is
responsible for filtering on the clicked element and deciding what to
append.
Pass a Graph subclass to the constructor to restrict the
handler to that graph type. The handler is invoked when the active
graph's type matches the listed type or derives from it. Apply the
attribute multiple times on the same method to register it for several
graph types.
[GraphMenu(typeof(MyGraph))] static void AppendNewItems(GraphMenuContext context) { if (context.ClickedObject is INode node) { context.AppendAction("Custom/Inspect", () => Debug.Log(node)); } }
| Property | Description |
|---|---|
| GraphType | The Graph subclass the handler is restricted to. |
| Constructor | Description |
|---|---|
| GraphMenuAttribute | Initializes a new instance of the GraphMenuAttribute class. |