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

ConditionMenuAttribute

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 right-click contextual menu of a transition's condition list. Every time the menu opens, the decorated method is invoked with a ConditionMenuContext that exposes the condition under the cursor and lets the method append entries via MenuContext.AppendAction.

The decorated method must be static, return void, and take a single ConditionMenuContext parameter, which also exposes the transition and the rule the condition list belongs to. The user is responsible for filtering on the clicked condition and deciding what to append. The handler is invoked when the active 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 state machine types. MenuContext.ClickedObject is the clicked ICondition. It is the root group condition when the root row is clicked. It is null when the click doesn't land on any condition or group row. A condition defined by deriving from Condition or Condition<T0> is passed as that derived type.

 [ConditionMenu(typeof(MyStateMachine))]
 static void AppendNewItems(ConditionMenuContext context)
 {
     if (context.ClickedObject is ICondition condition)
     {
         context.AppendAction("Custom/Inspect", () => Debug.Log(condition));
     }
 }

Properties

Property Description
StateMachineType The StateMachine subclass the handler is restricted to.

Constructors

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