Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

Condition

class in Unity.GraphToolkit.Editor


Implements interfaces:ICondition

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

The base class for all user-accessible conditions in a Condition.StateMachine graph.

A condition is a single test evaluated on a transition; conditions are combined with the built-in group condition (logical AND/OR) to decide whether a transition is taken. Derive from Condition<T0> to define a custom condition type with its serialized value, or derive from this class directly to define a valueless condition, such as a trigger, displayed as a label-only row in the transition inspector.

To make a custom condition available in a state machine, decorate the derived type with UseWithStateMachineAttribute for the relevant Condition.StateMachine type. Conditions defined in the same assembly as the state machine are available without the attribute, unless the state machine sets StateMachineOptions.DisableAutoInclusionOfStatesFromStateMachineAssembly. Available conditions appear in the Add menu of a transition's condition list, labeled with the title of a ConditionAttribute applied to the condition type when present, otherwise with the condition type name formatted for display.

See also:

 [Serializable]
 [UseWithStateMachine(typeof(MyStateMachine))]
 [Condition("Health Threshold")]
 public class Health : Condition<float>
 {
     public override string Tooltip => "Compares the current health against this value.";
     protected override bool DisplayComparisonDropdown => true;
 }

Properties

Property Description
ID The globally unique identifier for this condition.
Rule The rule this condition belongs to, or null when the condition is not part of one.
StateMachine The Condition.StateMachine that contains this condition, or null when the condition is not part of a state machine.
Title The label displayed for the condition in the transition inspector.
Tooltip The text displayed when hovering over the condition in the transition inspector.