# Reference

### EditorActionButtonAttribute

an attribute class that is used for defining custom editor action buttons on static methods to draw them in component or object headers.

| type   | parameter  | description                                                                                                                                                                                               |
| ------ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| string | id         | unique per type. There can be multiple id with same value on different targetTypes                                                                                                                        |
| Type   | targetType | Show buttons on the target type and its derived types. If a type that derives from the target type is added separately with the same ID, the button will not be shown on that type and its derived types. |
| string | iconPath   | <p>path to an texture under the Assets/Editor Default Resources folder<br>e.g. "<del>Assets/Editor Default Resource/</del><strong>SubFolder/example.png</strong>" only the bold part should be used. </p> |
| string | tooltip    | small message to show on hover                                                                                                                                                                            |
| int    | priority   | button placement order                                                                                                                                                                                    |

**Use Case:**

```csharp
//Method can have both single parameter or array parameter. 
//Array sends all selected contexts and single sends only the first from selected.

[EditorActionButton("print", typeof(Transform), "SubFolder/example.png", 
"Print transform position", 0)]
private static void PrintTransform(Object context)
{
    Debug.Log(((Transform)context).position);
}

//---------------or---------------

[EditorActionButton("print", typeof(Transform), "SubFolder/example.png", 
"Print transform position", 0)]
private static void PrintTransform(Object[] contexts)
{
    foreach(var context in contexts)
    {
        Debug.Log(((Transform)context).position);
    }
}
```

### EditorActionButtonValidateAttribute

Helper attribute for show/hide/disable condition management of the button

| type   | parameter  | description                                                   |
| ------ | ---------- | ------------------------------------------------------------- |
| Type   | targetType | Determines which type's buttons should be under validation    |
| string | id         | used to find editor action button with this id for validation |

| return type | description                                       |
| ----------- | ------------------------------------------------- |
| ButtonState | tells what to do with the button after validation |

**Use Case:**

```csharp
//Method can have both single parameter or array parameter.
//Array sends all selected contexts and single sends only the first from selected

[EditorActionButtonValidate(typeof(Transform),"print")]
private static ButtonState PrintTransform(Object context)
{
    //Will hide button on rect transforms
    return (context is RectTransform) ?
         ButtonState.Hidden : ButtonState.Active;
}

//---------------or---------------

[EditorActionButtonValidate(typeof(Transform),"print")]
private static ButtonState PrintTransform(Object[] contexts)
{
    //Will hide button on rect transforms
    return (contexts.Any(ctx => ctx is RectTransform)) ? 
        ButtonState.Hidden : ButtonState.Active;
}
```

### GameObjectActionButtonAttribute

an attribute class that is used for defining custom editor action buttons on static methods to draw them in inspector header or hierarchy item

| type            | parameter     | description                                                                                                                                                                                               |
| --------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| string          | id            | unique per placementType. There can be multiple id with same value on different placementType                                                                                                             |
| GOPlacementType | placementType | Determines which area the buttons should draw on                                                                                                                                                          |
| string          | iconPath      | <p>path to an texture under the Assets/Editor Default Resources folder<br>e.g. "<del>Assets/Editor Default Resource/</del><strong>SubFolder/example.png</strong>" only the bold part should be used. </p> |
| string          | tooltip       | small message to show on hover                                                                                                                                                                            |
| int             | priority      | button placement order                                                                                                                                                                                    |

**Use Case:**

```csharp
//Method can have both single parameter or array parameter.
//Array sends all selected contexts and single sends only the first from selected

[EditorActionButton("print", GOPlacementType.Header, "SubFolder/example.png", 
"Print transform position", 0)]
private static void PrintComponentCount(GameObject context)
{
    var components = context.GetComponent<Component>();
    Debug.Log(components.Length);
}

//---------------or---------------

[EditorActionButton("print", GOPlacementType.Hierarchy, "SubFolder/example.png", 
"Print transform position", 0)]
private static void PrintComponentCount(GameObject[] contexts)
{
    foreach(GameObject context in contexts)
    {
        var components = context.GetComponent<Component>();
        Debug.Log(components.Length);
    }
}
```

### GameObjectActionButtonValidateAttribute

Helper attribute for show/hide/disable condition management of the button

| type            | parameter     | description                                                        |
| --------------- | ------------- | ------------------------------------------------------------------ |
| string          | id            | used to find game object action button with this id for validation |
| GOPlacementType | placementType | Determines which area the buttons should be validated on           |

**Use Case:**

```csharp
//Method can have both single parameter or array parameter.
//Array sends all selected contexts and single sends only the first from selected

[GameObjectActionValidate("print", GOPlacementType.Header)]
private static ButtonState PrintComponentCount(GameObject context)
{
    //Disable if target go is not a file asset
    return EditorUtility.IsPersistent(context) ?
        ButtonState.Disabled : ButtonState.Active;
}

//---------------or---------------

[GameObjectActionValidate("print", GOPlacementType.Header)]
private static void PrintComponentCount(GameObject[] contexts)
{
    //Disable if target go is not a file asset
    return context.All(ctx => EditorUtility.IsPersistent(ctx)) ?
        ButtonState.Disabled : ButtonState.Active;
}
```


---

# 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://rocketshiftstudio-assets.gitbook.io/invoke/reference.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.
