Version: Unity 6.7 Alpha (6000.7)
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, or null when the click landed on empty space in the condition list. 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.