> For the complete documentation index, see [llms.txt](https://docs.yarnspinner.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yarnspinner.dev/2.4/api/csharp/yarn.unity/yarn.unity.effects/yarn.unity.effects.pausabletypewriter.md).

# PausableTypewriter(TextMeshProUGUI,float,Action,Action,Action,Stack<(int position, float duration)>,CoroutineInterruptToken)

Method in [Effects](/2.4/api/csharp/yarn.unity/yarn.unity.effects.md)

## Summary

A coroutine that gradually reveals the text in a `TMPro.TextMeshProUGUI` object over time.

```csharp
public static IEnumerator PausableTypewriter(TextMeshProUGUI text, float lettersPerSecond, Action onCharacterTyped, Action onPauseStarted, Action onPauseEnded, Stack<(int position, float duration)> pausePositions, CoroutineInterruptToken stopToken = null)
```

## Remarks

Essentially identical to [Typewriter(TextMeshProUGUI,float,Action,CoroutineInterruptToken)](/2.4/api/csharp/yarn.unity/yarn.unity.effects/yarn.unity.effects.typewriter.md) but supports pausing the animation based on `pausePositions` values.

This method works by adjusting the value of the `text` parameter's `TextMeshProUGUI.maxVisibleCharacters` property. This means that word wrapping will not change half-way through the presentation of a word.

{% hint style="info" %}
Depending on the value of `lettersPerSecond`, `onCharacterTyped` may be called multiple times per frame.
{% endhint %}

Due to an internal implementation detail of TextMeshProUGUI, this method will always take at least one frame to execute, regardless of the length of the `text` parameter's text.

## Parameters

| Name                                                                                                                                                | Description                                                                                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `TMPro.TextMeshProUGUI` text                                                                                                                        | A TextMeshProUGUI object to reveal the text of                                                                                                                                                                                                                    |
| `float` lettersPerSecond                                                                                                                            | The number of letters that should be revealed per second.                                                                                                                                                                                                         |
| `System.Action` onCharacterTyped                                                                                                                    | An `System.Action` that should be called for each character that was revealed.                                                                                                                                                                                    |
| `System.Action` onPauseStarted                                                                                                                      | An `System.Action` that will be called when the typewriter effect is paused.                                                                                                                                                                                      |
| `System.Action` onPauseEnded                                                                                                                        | An `System.Action` that will be called when the typewriter effect is restarted.                                                                                                                                                                                   |
| `System.Collections.Generic.Stack<(int position, float duration)>` pausePositions                                                                   | A stack of character position and pause duration tuples used to pause the effect. Generally created by [GetPauseDurationsInsideLine(Markup.MarkupParseResult)](/2.4/api/csharp/yarn.unity/yarn.unity.lineview/yarn.unity.lineview.getpausedurationsinsideline.md) |
| [Yarn.Unity.Effects.CoroutineInterruptToken](/2.4/api/csharp/yarn.unity/yarn.unity.effects/yarn.unity.effects.coroutineinterrupttoken.md) stopToken | A [CoroutineInterruptToken](/2.4/api/csharp/yarn.unity/yarn.unity.effects/yarn.unity.effects.coroutineinterrupttoken.md) that can be used to interrupt the coroutine.                                                                                             |
