docs.unity3d.com
    Show / Hide Table of Contents

    Class GameObjectBrush

    This Brush instances, places and manipulates GameObjects onto the scene. Use this as an example to create brushes which targets objects other than tiles for manipulation.

    Inheritance
    Object
    Object
    ScriptableObject
    GridBrushBase
    GameObjectBrush
    Inherited Members
    GridBrushBase.Select(GridLayout, GameObject, BoundsInt)
    GridBrushBase.Move(GridLayout, GameObject, BoundsInt, BoundsInt)
    GridBrushBase.ChangeZPosition(Int32)
    GridBrushBase.ResetZPosition()
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(String)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    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, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    UnityEngine.Object.FindObjectsOfType(System.Type, System.Boolean)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
    Object.FindObjectOfType<T>()
    UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    UnityEngine.Object.FindObjectOfType(System.Type, System.Boolean)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: UnityEditor.Tilemaps
    Syntax
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@latest/index.html?subfolder=/manual/GameObjectBrush.html")]
    [CustomGridBrush(true, false, false, "GameObject Brush")]
    public class GameObjectBrush : GridBrushBase

    Constructors

    GameObjectBrush()

    This Brush instances, places and manipulates GameObjects onto the scene.

    Declaration
    public GameObjectBrush()

    Fields

    hiddenGrid

    GameObject used for painting onto the Scene root

    Declaration
    [HideInInspector]
    public GameObject hiddenGrid
    Field Value
    Type Description
    GameObject

    m_Anchor

    Anchor Point of the Instantiated GameObject in the cell when painting

    Declaration
    public Vector3 m_Anchor
    Field Value
    Type Description
    Vector3

    Properties

    cellCount

    Number of brush cells in the brush.

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

    cells

    All the brush cells the brush holds.

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

    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

    sizeCount

    Number of brush cells based on size.

    Declaration
    public int sizeCount { get; }
    Property Value
    Type Description
    Int32

    Methods

    BoxErase(GridLayout, GameObject, BoundsInt)

    Erases GameObjects from given bounds within the selected layers. The GameObjectBrush overrides this to provide GameObject box-erasing functionality.

    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 GameObjects into given bounds within the selected layers. The GameObjectBrush overrides this to provide GameObject box-filling functionality.

    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 GameObjects in a given position within the selected layers. The GameObjectBrush overrides this to provide GameObject erasing functionality.

    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(GridBrushBase.FlipAxis, GridLayout.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)

    This is not supported but it should floodfill 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(Int32, Int32, Int32)

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

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

    X Position of the BrushCell.

    Int32 y

    Y Position of the BrushCell.

    Int32 z

    Z Position of the BrushCell.

    Returns
    Type Description
    Int32

    The cell index for the position of the BrushCell.

    GetCellIndex(Int32, Int32, Int32, Int32, Int32, Int32)

    Gets the index to the GameObjectBrush::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
    Int32 x

    X Position of the BrushCell.

    Int32 y

    Y Position of the BrushCell.

    Int32 z

    Z Position of the BrushCell.

    Int32 sizex

    X Size of Brush.

    Int32 sizey

    Y Size of Brush.

    Int32 sizez

    Z Size of Brush.

    Returns
    Type Description
    Int32

    The cell index for the position of the BrushCell.

    GetCellIndex(Vector3Int)

    Gets the index to the GameObjectBrush::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
    Int32

    The cell index for the position of the BrushCell.

    GetCellIndexWrapAround(Int32, Int32, Int32)

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

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

    X Position of the BrushCell.

    Int32 y

    Y Position of the BrushCell.

    Int32 z

    Z Position of the BrushCell.

    Returns
    Type Description
    Int32

    The cell index for the position of the BrushCell.

    GetHashCode()

    Hashes the contents of the brush.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    A hash code of the brush

    Overrides
    Object.GetHashCode()

    Init(Vector3Int)

    Initializes the content of the GameObjectBrush.

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

    Size of the GameObjectBrush.

    Init(Vector3Int, Vector3Int)

    Initializes the content of the GameObjectBrush.

    Declaration
    public void Init(Vector3Int size, Vector3Int pivot)
    Parameters
    Type Name Description
    Vector3Int size

    Size of the GameObjectBrush.

    Vector3Int pivot

    Pivot point of the GameObjectBrush.

    MoveEnd(GridLayout, GameObject, BoundsInt)

    MoveEnd is called when user has ended the move of the area previously selected with the selection marquee. The GameObjectBrush overrides this to provide GameObject moving functionality.

    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. The GameObjectBrush overrides this to provide GameObject moving functionality.

    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 GameObjects into a given position within the selected layers. The GameObjectBrush overrides this to provide GameObject painting functionality.

    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 child GameObjects given the coordinates of the cells. The GameObjectBrush overrides this to provide GameObject picking functionality.

    Declaration
    public override void Pick(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, Vector3Int pivot)
    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 pivot

    Pivot of the picking brush.

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

    Reset()

    Clears all data of the brush.

    Declaration
    public void Reset()

    Rotate(GridBrushBase.RotationDirection, GridLayout.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)

    SetGameObject(Vector3Int, GameObject)

    Sets a GameObject at the position in the brush.

    Declaration
    public void SetGameObject(Vector3Int position, GameObject go)
    Parameters
    Type Name Description
    Vector3Int position

    Position to set the GameObject in the brush.

    GameObject go

    GameObject to set in the brush.

    SetOffset(Vector3Int, Vector3)

    Sets a position offset at the position in the brush.

    Declaration
    public void SetOffset(Vector3Int position, Vector3 offset)
    Parameters
    Type Name Description
    Vector3Int position

    Position to set the offset in the brush.

    Vector3 offset

    Offset to set in the brush.

    SetOrientation(Vector3Int, Quaternion)

    Sets an orientation at the position in the brush.

    Declaration
    public void SetOrientation(Vector3Int position, Quaternion orientation)
    Parameters
    Type Name Description
    Vector3Int position

    Position to set the orientation in the brush.

    Quaternion orientation

    Orientation to set in the brush.

    SetScale(Vector3Int, Vector3)

    Sets a scale at the position in the brush.

    Declaration
    public void SetScale(Vector3Int position, Vector3 scale)
    Parameters
    Type Name Description
    Vector3Int position

    Position to set the scale in the brush.

    Vector3 scale

    Scale 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 size, Vector3Int pivot)
    Parameters
    Type Name Description
    Vector3Int size

    New size of the brush.

    Vector3Int pivot

    New pivot of the brush.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023