# GridBrushBase

> Base class for authoring data on a grid with grid painting tools like paint, erase, pick, select and fill.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.TilemapModule
* **Inherits from:** [ScriptableObject](/engine/6000.0/script-reference/unityengine/scriptableobject.md)

```csharp
public abstract class GridBrushBase : ScriptableObject
```

## Remarks

Inheriting this class and/or creating brush asset instances from your inherited class, you can create custom brushes which react to high level grid events like paint, erase, pick, select and fill.

## Examples

```csharp
using UnityEngine;

// Paints two Prefabs in checkerboard pattern
[CreateAssetMenu]
public class CheckerboardBrush : GridBrushBase
{
    public GameObject prefabA;
    public GameObject prefabB;

    public override void Paint(GridLayout grid, GameObject brushTarget, Vector3Int position)
    {
        bool evenCell = Mathf.Abs(position.y + position.x) % 2 > 0;
        GameObject toBeInstantiated = evenCell ? prefabA : prefabB;

        if (toBeInstantiated != null)
        {
            GameObject newInstance = Instantiate(toBeInstantiated, grid.CellToWorld(position), Quaternion.identity);
            newInstance.transform.SetParent(brushTarget.transform);
        }
    }
}
```

## Methods

| Method                                                                                          | Description                                                                                                                                                           |
| ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [BoxErase](/engine/6000.0/script-reference/unityengine/gridbrushbase/boxerase.md)               | Erases data on a grid within the given bounds.                                                                                                                        |
| [BoxFill](/engine/6000.0/script-reference/unityengine/gridbrushbase/boxfill.md)                 | Box fills tiles and GameObjects into given bounds within the selected layers.                                                                                         |
| [ChangeZPosition](/engine/6000.0/script-reference/unityengine/gridbrushbase/changezposition.md) | Changes the Z position of the [GridBrushBase](/engine/6000.0/script-reference/unityengine/gridbrushbase.md).                                                          |
| [Erase](/engine/6000.0/script-reference/unityengine/gridbrushbase/erase.md)                     | Erases data on a grid within the given bounds.                                                                                                                        |
| [Flip](/engine/6000.0/script-reference/unityengine/gridbrushbase/flip.md)                       | Flips the grid brush in the given [GridBrushBase.FlipAxis](/engine/6000.0/script-reference/unityengine/gridbrushbase/flipaxis.md).                                    |
| [FloodFill](/engine/6000.0/script-reference/unityengine/gridbrushbase/floodfill.md)             | Flood fills data onto a grid given the starting coordinates of the cell.                                                                                              |
| [Move](/engine/6000.0/script-reference/unityengine/gridbrushbase/move.md)                       | Move is called when user moves the area previously selected with the selection marquee.                                                                               |
| [MoveEnd](/engine/6000.0/script-reference/unityengine/gridbrushbase/moveend.md)                 | MoveEnd is called when user has ended the move of the area previously selected with the selection marquee.                                                            |
| [MoveStart](/engine/6000.0/script-reference/unityengine/gridbrushbase/movestart.md)             | MoveEnd is called when user starts moving the area previously selected with the selection marquee.                                                                    |
| [Paint](/engine/6000.0/script-reference/unityengine/gridbrushbase/paint.md)                     | Paints data into a grid within the given bounds.                                                                                                                      |
| [Pick](/engine/6000.0/script-reference/unityengine/gridbrushbase/pick.md)                       | Picks data from a grid given the coordinates of the cells.                                                                                                            |
| [ResetZPosition](/engine/6000.0/script-reference/unityengine/gridbrushbase/resetzposition.md)   | Resets Z position changes of the [GridBrushBase](/engine/6000.0/script-reference/unityengine/gridbrushbase.md).                                                       |
| [Rotate](/engine/6000.0/script-reference/unityengine/gridbrushbase/rotate.md)                   | Rotates all tiles on the grid brush with the given [GridBrushBase.RotationDirection](/engine/6000.0/script-reference/unityengine/gridbrushbase/rotationdirection.md). |
| [Select](/engine/6000.0/script-reference/unityengine/gridbrushbase/select.md)                   | Select an area of a grid.                                                                                                                                             |

## Enums

| Enum                                                                                                              | Description                                                                                                          |
| ----------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| [GridBrushBase.FlipAxis](/engine/6000.0/script-reference/unityengine/gridbrushbase/flipaxis.md)                   | Axis to flip tiles in the GridBrushBase by.                                                                          |
| [GridBrushBase.RotationDirection](/engine/6000.0/script-reference/unityengine/gridbrushbase/rotationdirection.md) | Rotate tiles in the [GridBrushBase](/engine/6000.0/script-reference/unityengine/gridbrushbase.md) in this direction. |
| [GridBrushBase.Tool](/engine/6000.0/script-reference/unityengine/gridbrushbase/tool.md)                           | Options for the Tool mode of the [GridBrushBase](/engine/6000.0/script-reference/unityengine/gridbrushbase.md).      |

## Inheritance

**Inherited Members:**

* [ScriptableObject.CreateInstance(string)](/engine/6000.0/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(string\))
* [ScriptableObject.CreateInstance(Type)](/engine/6000.0/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(type\))
* [ScriptableObject.CreateInstance\<T>()](/engine/6000.0/script-reference/unityengine/scriptableobject/createinstance.md)
* [Object.GetInstanceID()](/engine/6000.0/script-reference/unityengine/object/getinstanceid.md)
* [Object.GetHashCode()](/engine/6000.0/script-reference/unityengine/object/gethashcode.md)
* [Object.InstantiateAsync\<T>(T)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.Instantiate(Object, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion\))
* [Object.Instantiate(Object, Vector3, Quaternion, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion-transform\))
* [Object.Instantiate(Object)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object\))
* [Object.Instantiate(Object, Scene)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-scene\))
* [Object.Instantiate\<T>(T, InstantiateParameters)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, InstantiateParameters)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate(Object, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform\))
* [Object.Instantiate(Object, Transform, bool)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform-bool\))
* [Object.Instantiate\<T>(T)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform, bool)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Destroy(Object, float)](/engine/6000.0/script-reference/unityengine/object/destroy.md)
* [Object.DestroyImmediate(Object, bool)](/engine/6000.0/script-reference/unityengine/object/destroyimmediate.md)
* [Object.FindObjectsByType(Type, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectssortmode\))
* [Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectsinactive-findobjectssortmode\))
* [Object.DontDestroyOnLoad(Object)](/engine/6000.0/script-reference/unityengine/object/dontdestroyonload.md)
* [Object.FindObjectsByType\<T>(FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectssortmode\))
* [Object.FindObjectsByType\<T>(FindObjectsInactive, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectsinactive-findobjectssortmode\))
* [Object.FindFirstObjectByType\<T>()](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytypet\(\))
* [Object.FindAnyObjectByType\<T>()](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(\))
* [Object.FindFirstObjectByType\<T>(FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytypet\(findobjectsinactive\))
* [Object.FindAnyObjectByType\<T>(FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(findobjectsinactive\))
* [Object.FindFirstObjectByType(Type)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytype\(type\))
* [Object.FindAnyObjectByType(Type)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type\))
* [Object.FindFirstObjectByType(Type, FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytype\(type-findobjectsinactive\))
* [Object.FindAnyObjectByType(Type, FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type-findobjectsinactive\))
* [Object.ToString()](/engine/6000.0/script-reference/unityengine/object/tostring.md)
* [Object.name](/engine/6000.0/script-reference/unityengine/object/name.md)
* [Object.hideFlags](/engine/6000.0/script-reference/unityengine/object/hideflags.md)

### Operators

| Operator                                                                           | Description                                                             |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [operator ==](/engine/6000.0/script-reference/unityengine/object/op-equality.md)   | Compares two object references to see if they refer to the same object. |
| [bool](/engine/6000.0/script-reference/unityengine/object/op-implicit.md)          | Determines whether the object exists.                                   |
| [operator !=](/engine/6000.0/script-reference/unityengine/object/op-inequality.md) | Compares if two objects refer to a different object.                    |
