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.
Namespace: UnityEditor.Tilemaps
Syntax
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
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. |
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. |
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. |
Flip(FlipAxis, GridLayout.CellLayout)
Flips the brush in the given axis.
Declaration
public override void Flip(FlipAxis flip, GridLayout.CellLayout layout)
Parameters
| Type | Name | Description |
|---|---|---|
| FlipAxis | flip | Axis to flip by. |
| GridLayout.CellLayout | layout | Cell Layout for flipping. |
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. |
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 |
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. |
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. |
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. |
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. |
Reset()
Clears all data of the brush.
Declaration
public void Reset()
Rotate(RotationDirection, GridLayout.CellLayout)
Rotates the brush by 90 degrees in the given direction.
Declaration
public override void Rotate(RotationDirection direction, GridLayout.CellLayout layout)
Parameters
| Type | Name | Description |
|---|---|---|
| RotationDirection | direction | Direction to rotate by. |
| GridLayout.CellLayout | layout | Cell Layout for rotating. |
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. |