> For the complete documentation index, see [llms.txt](https://docs.febucci.com/text-animator-unity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.febucci.com/text-animator-unity/2.x/extra-customization-via-c/writing-custom-actions-c.md).

# Writing Custom Actions (C#)

Other than using [built-in actions](https://docs.febucci.com/text-animator-unity/typewriter/wait-actions-when-typing), you can write your own via script (C#).

***

### Actions Base Class <a href="#actions-base-class" id="actions-base-class"></a>

When creating a new class, inherit from `Febucci.UI.Actions.ActionScriptableBase` ([Scripting API](https://www.api.febucci.com/tools/text-animator-unity/api/Febucci.UI.Actions.ActionScriptableBase.html)).

```csharp
public class CustomAction : ActionScriptableBase
{
    //[...]
```

### Attributes <a href="#attributes" id="attributes"></a>

Since you’re creating a ScriptableObject, just like Events, make sure to add the needed attributes as well in order to instance and serialize them:

```csharp
[CreateAssetMenu(fileName = "YourCustomAction", menuName = "Text Animator/Custom/YourCustomAction")]
[System.Serializable]
public class CustomAction : ActionScriptableBase
{
    //[...]
```

This way you’ll be able to create them from your Project Window.

### DoAction Method <a href="#doaction-method" id="doaction-method"></a>

Then, all you need to do is overriding the “DoAction” method and write your code inside it.

Remember that actions **pause** the typewriter until they’re completed (for example, waiting for player input or until time has passed).

```csharp
public override IEnumerator DoAction(ActionMarker action, TypewriterCore typewriter, TypingInfo typingInfo)
{
    //[...]
}
```

* The `action` paramater has useful info about your tag, for example the ID or if there are any parameters that come with it (e.g. `<playSound=02>`).
* The `typewriter` references the component that is currently performing the action
* The `typingInfo` contains information such as the current typing speed (which you can modify) and time passed inside the typewriter.

Please refer to the <mark style="background-color:orange;">Scripting API</mark> to have a complete view of the classes and more.

***

### ✅ Done! <a href="#done" id="done"></a>

Done! With this simple procedure, you can add any Custom Action you want.

P.S. Don’t forget to create your action ScriptableObject in the ProjectView, and add it to an actions Database.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
