# onCommand

Field in [DialogueRunner](https://docs.yarnspinner.dev/2.0/api/csharp/yarn.unity/yarn.unity.dialoguerunner)

## Summary

A [StringUnityEvent](https://docs.yarnspinner.dev/2.0/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.stringunityevent) that is called when a `Command` is received.

```csharp
public StringUnityEvent onCommand;
```

## Remarks

Use this method to dispatch a command to other parts of your game. This method is only called if the `Command` has not been handled by a command handler that has been added to the [DialogueRunner](https://docs.yarnspinner.dev/2.0/api/csharp/yarn.unity/yarn.unity.dialoguerunner), or by a method on a `MonoBehaviour` in the scene with the attribute [YarnCommandAttribute](https://docs.yarnspinner.dev/2.0/api/csharp/yarn.unity/yarn.unity.yarncommandattribute).

When a command is delivered in this way, the [DialogueRunner](https://docs.yarnspinner.dev/2.0/api/csharp/yarn.unity/yarn.unity.dialoguerunner) will not pause execution. If you want a command to make the DialogueRunner pause execution, see `AddCommandHandler(string, CommandHandler)`.

This method receives the full text of the command, as it appears between the `<<` and `>>` markers.

## See Also

* AddCommandHandler(string, CommandHandler)
* AddCommandHandler(string, CommandHandler)
* [YarnCommandAttribute](https://docs.yarnspinner.dev/2.0/api/csharp/yarn.unity/yarn.unity.yarncommandattribute): An attribute that marks a method on an object as a command.
