> 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.
