ConditionMenuAttribute
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.
Read time 4 minutesLast updated 7 days ago
Definition
- Type: Class
- Namespace: Unity.GraphToolkit.Editor
- Assembly: UnityEditor
- Inherits from: Attribute
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]public sealed class ConditionMenuAttribute : Attribute
Remarks
The decorated method must be , return , 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.
staticvoidThe 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 when the click doesn't land on any condition or group row. A condition defined by deriving from Condition or Condition<T> is passed as that derived type.
nullExamples
[ConditionMenu(typeof(MyStateMachine))]static void AppendNewItems(ConditionMenuContext context){ if (context.ClickedObject is ICondition condition) { context.AppendAction("Custom/Inspect", () => Debug.Log(condition)); }}
Constructors
Constructor | Description |
|---|---|
| ConditionMenuAttribute(System.Type) | Initializes a new instance of the ConditionMenuAttribute class. |
Properties
Property | Description |
|---|---|
| StateMachineType | The StateMachine subclass the handler is restricted to. |