# YarnFunctionAttribute

Class in [Yarn.Unity](/3.1/api/csharp/yarn.unity.md)

Inherits from [`YarnActionAttribute`](/3.1/api/csharp/yarn.unity/yarn.unity.yarnactionattribute.md)

## Summary

Marks the method as a function to be registered with the running instance's library.

```csharp
public class YarnFunctionAttribute : YarnActionAttribute
```

## Remarks

See [RegisterFunction(string,Delegate)](/3.1/api/csharp/yarn/yarn.library/yarn.library.registerfunction-7.md) and the generic overloads for what is and is not valid.

This will throw an error if you attempt to add a function that has more than 16 parameters, as that is the largest overload that ``System.Func`1`` etc has.

Yarn Spinner for Unity finds methods with the YarnFunction attribute by reading your source code. If your project uses Unity 2021.1 or earlier, you will need to tell Yarn Spinner for Unity to do this manually, by opening the Window method and choosing Yarn Spinner -> Update Yarn Commands. You don't need to do this on later versions of Unity, as it will be done for you automatically when your code compiles.


---

# 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.yarnspinner.dev/3.1/api/csharp/yarn.unity/yarn.unity.yarnfunctionattribute.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.
