Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

GraphMenuAttribute

class in Unity.GraphToolkit.Editor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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 context that exposes the element under the cursor and lets the method append entries via MenuContext.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. 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. MenuContext.ClickedObject is the element under the cursor: an INode, an IPort or a Wire. The value is null when the click landed on empty space or on an element that is not exposed through the public API. To contribute entries to the state machine view, use StateMachineMenuAttribute. For the blackboard, use BlackboardMenuAttribute. For the condition list of a transition inspector, use ConditionMenuAttribute.

 [GraphMenu(typeof(MyGraph))]
 static void AppendGraphItems(GraphMenuContext context)
 {
     if (context.ClickedObject is INode node)
         context.AppendAction("Custom/Inspect", () => Debug.Log(node));
 }

Properties

Property Description
GraphType The Graph subclass the handler is restricted to.

Constructors

Constructor Description
GraphMenuAttribute Initializes a new instance of the GraphMenuAttribute class.