BlackboardMenuAttribute
Marks a static method as a contributor to the blackboard'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.
Read time 4 minutesLast updated 6 days ago
Definition
- Type: Class
- Namespace: Unity.GraphToolkit.Editor
- Assembly: UnityEditor
- Inherits from: Attribute
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]public sealed class BlackboardMenuAttribute : Attribute
Remarks
The decorated method must be , return , and take a single context parameter. The type passed to the constructor decides which context type: a Graph subclass requires a GraphMenuContext parameter, a StateMachine subclass requires a StateMachineMenuContext parameter. The user is responsible for filtering on the clicked element and deciding what to append.
staticvoidThe handler is invoked when the active graph or state machine's type matches the listed type or derives from it. Apply the attribute multiple times on the same method to register it for several types, as long as they all require the same context type. MenuContext.ClickedObject is the clicked IVariable, or when the click landed on empty space in the blackboard.
nullExamples
[BlackboardMenu(typeof(MyGraph))]static void AppendNewItems(GraphMenuContext context){ if (context.ClickedObject is IVariable variable) { context.AppendAction("Int/Reset", () => Debug.Log(variable)); }}
Constructors
Constructor | Description |
|---|---|
| BlackboardMenuAttribute(System.Type) | Initializes a new instance of the BlackboardMenuAttribute class. |
Properties
Property | Description |
|---|---|
| GraphType | The Graph or StateMachine subclass the handler is restricted to. |