docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GridBrush

    Default built-in brush for painting or erasing tiles and/or gameobjects on a grid.

    Inheritance
    object
    Object
    ScriptableObject
    GridBrushBase
    GridBrush
    Inherited Members
    GridBrushBase.Select(GridLayout, GameObject, BoundsInt)
    GridBrushBase.Move(GridLayout, GameObject, BoundsInt, BoundsInt)
    GridBrushBase.ChangeZPosition(int)
    GridBrushBase.ResetZPosition()
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(string)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.InstantiateAsync<T>(T, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate<T>(T, InstantiateParameters)
    Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEditor.Tilemaps
    Assembly: Unity.2D.Tilemap.Editor.dll
    Syntax
    [MovedFrom(true, "UnityEditor", "UnityEditor", null)]
    public class GridBrush : GridBrushBase
    Remarks

    Default brush is meant for two things: Authoring GameObjects on a grid and authoring tiles on a grid. It can be used for both at the same time if necessary. Basically the default brush allows you to pick and paste tiles and GameObjects from one area to another.

    Tiles in a tilemap are considered to be active for brush editing if a GameObject with Tilemap is currently selected. GameObjects are considered to be active for brush editing if their parent GameObject is currently selected.

    For example: A new default brush with size of 2x3 is generated as a result of Scene view picking operation. The new instance contains six cells (GridBrush.BrushCell) and the cells are fed with tiles & GameObjects from the picking area.

    Later when this brush is used in a painting operation, all the tiles and GameObjects contained in the cells are set/cloned into a new Scene position.

    When creating custom brushes, it is recommended to inherit GridBrushBase by default. Inheriting GridBrush is possible when similar functionality is required, but extending it has its limits compared to base class.

    It is also possible to replace the default GridBrush from the Tile Palette brush list completely by using the GridDefaultBrush attribute on one of your custom brushes and promote it to become a new default brush of the project. This is useful when higher level brush can operate as a default and protect designers from accidentally using the built-in one.

    Constructors

    GridBrush()

    Default built-in brush for painting or erasing Tiles and/or GameObjects on a Grid.

    Declaration
    public GridBrush()

    Properties

    canChangeZPosition

    Whether the brush can change Z Position

    Declaration
    public bool canChangeZPosition { get; set; }
    Property Value
    Type Description
    bool

    cellCount

    Number of brush cells in the brush.

    Declaration
    public int cellCount { get; }
    Property Value
    Type Description
    int

    cells

    All the brush cells the brush holds.

    Declaration
    public GridBrush.BrushCell[] cells { get; }
    Property Value
    Type Description
    BrushCell[]

    lastPickedCellGap

    Cell Gap of the Grid which the GridBrush last picked from.

    Declaration
    public Vector3 lastPickedCellGap { get; }
    Property Value
    Type Description
    Vector3

    lastPickedCellLayout

    Cell Layout of the Grid which the GridBrush last picked from.

    Declaration
    public GridLayout.CellLayout lastPickedCellLayout { get; }
    Property Value
    Type Description
    GridLayout.CellLayout

    lastPickedCellSize

    Cell Size of the Grid which the GridBrush last picked from.

    Declaration
    public Vector3 lastPickedCellSize { get; }
    Property Value
    Type Description
    Vector3

    lastPickedCellSwizzle

    Cell Swizzle of the Grid which the GridBrush last picked from.

    Declaration
    public GridLayout.CellSwizzle lastPickedCellSwizzle { get; }
    Property Value
    Type Description
    GridLayout.CellSwizzle

    pivot

    Pivot of the brush.

    Declaration
    public Vector3Int pivot { get; set; }
    Property Value
    Type Description
    Vector3Int

    size

    Size of the brush in cells.

    Declaration
    public Vector3Int size { get; set; }
    Property Value
    Type Description
    Vector3Int

    Methods

    BoxErase(GridLayout, GameObject, BoundsInt)

    Erases tiles and GameObjects from given bounds within the selected layers.

    Declaration
    public override void BoxErase(GridLayout gridLayout, GameObject brushTarget, BoundsInt position)
    Parameters
    Type Name Description
    GridLayout gridLayout

    Grid to erase data from.

    GameObject brushTarget

    Target of the erase operation. By default the currently selected GameObject.

    BoundsInt position

    The bounds to erase data from.

    Overrides
    GridBrushBase.BoxErase(GridLayout, GameObject, BoundsInt)

    BoxFill(GridLayout, GameObject, BoundsInt)

    Box fills tiles and GameObjects into given bounds within the selected layers.

    Declaration
    public override void BoxFill(GridLayout gridLayout, GameObject brushTarget, BoundsInt position)
    Parameters
    Type Name Description
    GridLayout gridLayout

    Grid to box fill data to.

    GameObject brushTarget

    Target of the box fill operation. By default the currently selected GameObject.

    BoundsInt position

    The bounds to box fill data into.

    Overrides
    GridBrushBase.BoxFill(GridLayout, GameObject, BoundsInt)

    Erase(GridLayout, GameObject, Vector3Int)

    Erases tiles and GameObjects in a given position within the selected layers.

    Declaration
    public override void Erase(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
    Parameters
    Type Name Description
    GridLayout gridLayout

    Grid used for layout.

    GameObject brushTarget

    Target of the erase operation. By default the currently selected GameObject.

    Vector3Int position

    The coordinates of the cell to erase data from.

    Overrides
    GridBrushBase.Erase(GridLayout, GameObject, Vector3Int)

    Flip(FlipAxis, CellLayout)

    Flips the brush in the given axis.

    Declaration
    public override void Flip(GridBrushBase.FlipAxis flip, GridLayout.CellLayout layout)
    Parameters
    Type Name Description
    GridBrushBase.FlipAxis flip

    Axis to flip by.

    GridLayout.CellLayout layout

    Cell Layout for flipping.

    Overrides
    UnityEngine.GridBrushBase.Flip(UnityEngine.GridBrushBase.FlipAxis, UnityEngine.GridLayout.CellLayout)

    FloodFill(GridLayout, GameObject, Vector3Int)

    Flood fills tiles and GameObjects starting from a given position within the selected layers.

    Declaration
    public override void FloodFill(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
    Parameters
    Type Name Description
    GridLayout gridLayout

    Grid used for layout.

    GameObject brushTarget

    Target of the flood fill operation. By default the currently selected GameObject.

    Vector3Int position

    Starting position of the flood fill.

    Overrides
    GridBrushBase.FloodFill(GridLayout, GameObject, Vector3Int)

    GetCellIndex(int, int, int)

    Gets the index to the GridBrush::ref::BrushCell based on the position of the BrushCell.

    Declaration
    public int GetCellIndex(int x, int y, int z)
    Parameters
    Type Name Description
    int x

    X Position of the BrushCell.

    int y

    Y Position of the BrushCell.

    int z

    Z Position of the BrushCell.

    Returns
    Type Description
    int

    The index to the GridBrush::ref::BrushCell.

    GetCellIndex(int, int, int, int, int, int)

    Gets the index to the GridBrush::ref::BrushCell based on the position of the BrushCell.

    Declaration
    public int GetCellIndex(int x, int y, int z, int sizex, int sizey, int sizez)
    Parameters
    Type Name Description
    int x

    X Position of the BrushCell.

    int y

    Y Position of the BrushCell.

    int z

    Z Position of the BrushCell.

    int sizex

    X Size of Brush.

    int sizey

    Y Size of Brush.

    int sizez

    Z Size of Brush.

    Returns
    Type Description
    int

    The index to the GridBrush::ref::BrushCell.

    GetCellIndex(Vector3Int)

    Gets the index to the GridBrush::ref::BrushCell based on the position of the BrushCell.

    Declaration
    public int GetCellIndex(Vector3Int brushPosition)
    Parameters
    Type Name Description
    Vector3Int brushPosition

    Position of the BrushCell.

    Returns
    Type Description
    int

    The index to the GridBrush::ref::BrushCell.

    GetCellIndexWrapAround(int, int, int)

    Gets the index to the GridBrush::ref::BrushCell based on the position of the BrushCell. Wraps each coordinate if it is larger than the size of the GridBrush.

    Declaration
    public int GetCellIndexWrapAround(int x, int y, int z)
    Parameters
    Type Name Description
    int x

    X Position of the BrushCell.

    int y

    Y Position of the BrushCell.

    int z

    Z Position of the BrushCell.

    Returns
    Type Description
    int

    The index to the GridBrush::ref::BrushCell.

    GetHashCode()

    Returns a HashCode for the GridBrush based on its contents.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A HashCode for the GridBrush based on its contents.

    Overrides
    UnityEngine.Object.GetHashCode()

    Init(Vector3Int)

    Initializes the content of the GridBrush.

    Declaration
    public void Init(Vector3Int newSize)
    Parameters
    Type Name Description
    Vector3Int newSize

    Size of the GridBrush.

    Init(Vector3Int, Vector3Int)

    Initializes the content of the GridBrush.

    Declaration
    public void Init(Vector3Int newSize, Vector3Int newPivot)
    Parameters
    Type Name Description
    Vector3Int newSize

    Size of the GridBrush.

    Vector3Int newPivot

    Pivot point of the GridBrush.

    MoveEnd(GridLayout, GameObject, BoundsInt)

    MoveEnd is called when user has ended the move of the area previously selected with the selection marquee.

    Declaration
    public override void MoveEnd(GridLayout gridLayout, GameObject brushTarget, BoundsInt position)
    Parameters
    Type Name Description
    GridLayout gridLayout

    Grid used for layout.

    GameObject brushTarget

    Target of the move operation. By default the currently selected GameObject.

    BoundsInt position

    Position where the move operation has ended.

    Overrides
    GridBrushBase.MoveEnd(GridLayout, GameObject, BoundsInt)

    MoveStart(GridLayout, GameObject, BoundsInt)

    MoveStart is called when user starts moving the area previously selected with the selection marquee.

    Declaration
    public override void MoveStart(GridLayout gridLayout, GameObject brushTarget, BoundsInt position)
    Parameters
    Type Name Description
    GridLayout gridLayout

    Grid used for layout.

    GameObject brushTarget

    Target of the move operation. By default the currently selected GameObject.

    BoundsInt position

    Position where the move operation has started.

    Overrides
    GridBrushBase.MoveStart(GridLayout, GameObject, BoundsInt)

    Paint(GridLayout, GameObject, Vector3Int)

    Paints tiles and GameObjects into a given position within the selected layers.

    Declaration
    public override void Paint(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
    Parameters
    Type Name Description
    GridLayout gridLayout

    Grid used for layout.

    GameObject brushTarget

    Target of the paint operation. By default the currently selected GameObject.

    Vector3Int position

    The coordinates of the cell to paint data to.

    Overrides
    GridBrushBase.Paint(GridLayout, GameObject, Vector3Int)

    Pick(GridLayout, GameObject, BoundsInt, Vector3Int)

    Picks tiles from selected Tilemaps and child GameObjects, given the coordinates of the cells.

    Declaration
    public override void Pick(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, Vector3Int pickStart)
    Parameters
    Type Name Description
    GridLayout gridLayout

    Grid to pick data from.

    GameObject brushTarget

    Target of the picking operation. By default the currently selected GameObject.

    BoundsInt position

    The coordinates of the cells to paint data from.

    Vector3Int pickStart

    Pivot of the picking brush.

    Overrides
    GridBrushBase.Pick(GridLayout, GameObject, BoundsInt, Vector3Int)

    Reset()

    Clears all data of the brush.

    Declaration
    public void Reset()

    Rotate(RotationDirection, CellLayout)

    Rotates the brush by 90 degrees in the given direction.

    Declaration
    public override void Rotate(GridBrushBase.RotationDirection direction, GridLayout.CellLayout layout)
    Parameters
    Type Name Description
    GridBrushBase.RotationDirection direction

    Direction to rotate by.

    GridLayout.CellLayout layout

    Cell Layout for rotating.

    Overrides
    UnityEngine.GridBrushBase.Rotate(UnityEngine.GridBrushBase.RotationDirection, UnityEngine.GridLayout.CellLayout)

    SetColor(Vector3Int, Color)

    Sets a tint color at the position in the brush.

    Declaration
    public void SetColor(Vector3Int position, Color color)
    Parameters
    Type Name Description
    Vector3Int position

    Position to set the color in the brush.

    Color color

    Tint color to set in the brush.

    SetMatrix(Vector3Int, Matrix4x4)

    Sets a transform matrix at the position in the brush. This matrix is used specifically for tiles on a Tilemap and not GameObjects of the brush cell.

    Declaration
    public void SetMatrix(Vector3Int position, Matrix4x4 matrix)
    Parameters
    Type Name Description
    Vector3Int position

    Position to set the transform matrix in the brush.

    Matrix4x4 matrix

    Transform matrix to set in the brush.

    SetTile(Vector3Int, TileBase)

    Sets a Tile at the position in the brush.

    Declaration
    public void SetTile(Vector3Int position, TileBase tile)
    Parameters
    Type Name Description
    Vector3Int position

    Position to set the tile in the brush.

    TileBase tile

    Tile to set in the brush.

    UpdateSizeAndPivot(Vector3Int, Vector3Int)

    Updates the size, pivot and the number of layers of the brush.

    Declaration
    public void UpdateSizeAndPivot(Vector3Int newSize, Vector3Int newPivot)
    Parameters
    Type Name Description
    Vector3Int newSize

    New size of the brush.

    Vector3Int newPivot

    New pivot of the brush.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)