# AddRule

> Creates a new empty transition rule and appends it to this transition.

## Definition

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

## AddRule()

Creates a new empty transition rule and appends it to this transition.

```csharp
ITransitionRule AddRule()
```

### Returns

| Type                                                                                            | Description                                                                                                        |
| ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [ITransitionRule](/engine/6000.7/script-reference/unity/graphtoolkit/editor/itransitionrule.md) | The newly created [ITransitionRule](/engine/6000.7/script-reference/unity/graphtoolkit/editor/itransitionrule.md). |

### Remarks

The new rule is added at the end of the transition rule set.

## AddRule(ITransitionRule)

Adds an existing rule to this transition.

```csharp
void AddRule(ITransitionRule rule)
```

### Parameters

**** (\[ITransitionRule]\(/engine/6000.7/script-reference/unity/graphtoolkit/editor/itransitionrule)): The rule to add.

### Remarks

If the `rule` already belongs to another transition of the same state machine, it is first removed from that transition: the rule is moved, not copied. A rule cannot be moved between state machines. Because a transition always keeps at least one rule, a rule cannot be moved out of a transition that holds it as its only rule; use [StateMachine.Disconnect](/engine/6000.7/script-reference/unity/graphtoolkit/editor/statemachine/disconnect.md) to remove that transition instead. The rule is added at the end of the transition rule set. Throws ArgumentNullException when `rule` is `null`. Throws ArgumentException when `rule` is not a valid rule, already belongs to a transition in another state machine, or is not accepted by this transition. Throws InvalidOperationException when `rule` is the last rule of the transition it belongs to.
