# Condition

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

## Definition

* **Type:** Class
* **Namespace:** [Unity.GraphToolkit.Editor](/engine/6000.7/script-reference/unity/graphtoolkit/editor.md)
* **Assembly:** UnityEditor
* **Implements:** [ICondition](/engine/6000.7/script-reference/unity/graphtoolkit/editor/icondition.md)

```csharp
public abstract class Condition : ICondition
```

## Remarks

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\<T>](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition1.md) 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](/engine/6000.7/script-reference/unity/graphtoolkit/editor/usewithstatemachineattribute.md) for the relevant [Condition.StateMachine](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/statemachine.md) type. Conditions defined in the same assembly as the state machine are available without the attribute, unless the state machine sets [StateMachineOptions.DisableAutoInclusionOfStatesFromStateMachineAssembly](/engine/6000.7/script-reference/unity/graphtoolkit/editor/statemachineoptions/disableautoinclusionofstatesfromstatemachineassembly.md). Available conditions appear in the `Add` menu of a transition's condition list, labeled with the title of a [ConditionAttribute](/engine/6000.7/script-reference/unity/graphtoolkit/editor/conditionattribute.md) applied to the condition type when present, otherwise with the condition type name formatted for display.

See also:

* [Condition\<T>](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition1.md) for the base class used to define custom conditions

* [ConditionView\<T>](/engine/6000.7/script-reference/unity/graphtoolkit/editor/conditionview1.md) for adding custom UI to a condition's row in the transition inspector

* [Condition.StateMachine](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/statemachine.md) for the graph type that contains transitions and conditions

* [State](/engine/6000.7/script-reference/unity/graphtoolkit/editor/state.md) for the base class used to define custom states

* [IGroupCondition](/engine/6000.7/script-reference/unity/graphtoolkit/editor/igroupcondition.md) for reading a transition's condition hierarchy

## Examples

```csharp
[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                                                                                                                                                                                                  |
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Icon](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/icon.md)                 | The icon displayed for this condition in the transition inspector, or `null` if none is set.                                                                                                                 |
| [ID](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/id.md)                     | The globally unique identifier for this condition.                                                                                                                                                           |
| [Rule](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/rule.md)                 | The rule this condition belongs to, or `null` when the condition is not part of one.                                                                                                                         |
| [StateMachine](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/statemachine.md) | The [Condition.StateMachine](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/statemachine.md) that contains this condition, or `null` when the condition is not part of a state machine. |
| [Title](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/title.md)               | The label displayed for the condition in the transition inspector.                                                                                                                                           |
| [Tooltip](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/tooltip.md)           | The text displayed when hovering over the condition in the transition inspector.                                                                                                                             |

## Static Methods

| Method                                                                                                                    | Description                          |
| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| [CreateGroupCondition](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/creategroupcondition.md)       | Creates a new empty group condition. |
| [CreateVariableCondition](/engine/6000.7/script-reference/unity/graphtoolkit/editor/condition/createvariablecondition.md) | Creates a new variable condition.    |
