Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

BlackboardMenuAttribute

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 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.

The decorated method must be static, return void, 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. The 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 null when the click landed on empty space in the blackboard.

 [BlackboardMenu(typeof(MyGraph))]
 static void AppendNewItems(GraphMenuContext context)
 {
     if (context.ClickedObject is IVariable variable)
     {
         context.AppendAction("Int/Reset", () => Debug.Log(variable));
     }
 }

Properties

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

Constructors

Constructor Description
BlackboardMenuAttribute Initializes a new instance of the BlackboardMenuAttribute class.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961