# Writing Custom Typewriters (C#)

By using “Text Animator for Unity” you can create your own **custom typewriters**, setting different types of delays between letters and much more.\
(If you want to learn about the default typewriter instead, [read here](/text-animator-unity/2.x/typewriter/show-and-hide-letters-dynamically.md)).

***

## Adding Custom Typewriters <a href="#adding-custom-typewriters" id="adding-custom-typewriters"></a>

In order to create a custom typewriter for your game, you need to to create a custom class that inherits from `Febucci.UI.Core.TypewriterCore` \[[Scripting API](https://www.api.febucci.com/tools/text-animator-unity/api/Febucci.UI.Core.TypewriterCore.html)].

### Fundamental Methods <a href="#fundamental-methods" id="fundamental-methods"></a>

You have to override/implement the following methods:

#### float GetWaitAppearanceTimeOf(int charIndex) <a href="#float-getwaitappearancetimeofint-charindex" id="float-getwaitappearancetimeofint-charindex"></a>

It tells the typewriter how much time to wait for each character. This way, you can implement your own special characters that need an unique wait time and more.

You can access the character from the index by doing as follows:

```csharp
char character = TextAnimator.Characters[charIndex].info.character
```

For example, in order to have a different wait time when typing punctuations:

```csharp

[SerializeField] float normalTime = .1f;
[SerializeField] float punctuationTime = .3f;
protected override float GetWaitAppearanceTimeOf(int charIndex)
{
    char character = TextAnimator.Characters[charIndex].info.character;
    return char.IsPunctuation(character) ? punctuationTime : normalTime;
}
```

***

### Optional Methods <a href="#optional-methods" id="optional-methods"></a>

You can also override the following methods for extra functionalities.

#### float GetWaitDisappearanceTimeOf(int charIndex) <a href="#float-getwaitdisappearancetimeofint-charindex" id="float-getwaitdisappearancetimeofint-charindex"></a>

Override this method in case you want different disappearance wait times/speed. Otherwise, your custom textAnimatorPlayer will use the same delays as its typewriter (GetWaitAppearanceTimeOf);

***

✅ That’s it! Really!

👍🏻 Don’t forget to add your typewriter component on the same gameObject that has a TextAnimator one.

Have fun implementing your own typewriters <3


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.febucci.com/text-animator-unity/2.x/extra-customization-via-c/writing-custom-typewriters-c.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
