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.
Inherited Members
Namespace: UnityEditor .Tilemaps
Assembly: Unity.2D.Tilemap.Extras.Editor.dll
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 |
---|---|
Game |
m_Anchor
Anchor Point of the Instantiated GameObject in the cell when painting
Declaration
public Vector3 m_Anchor
Field Value
Type | Description |
---|---|
Vector3 |
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 GameObjectBrush.BrushCell[] cells { get; }
Property Value
Type | Description |
---|---|
Brush |
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 |
---|---|
int |
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 |
---|---|---|
Grid |
gridLayout | Grid to erase data from. |
Game |
brushTarget | Target of the erase operation. By default the currently selected GameObject. |
Bounds |
position | The bounds to erase data from. |
Overrides
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 |
---|---|---|
Grid |
gridLayout | Grid to box fill data to. |
Game |
brushTarget | Target of the box fill operation. By default the currently selected GameObject. |
Bounds |
position | The bounds to box fill data into. |
Overrides
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 |
---|---|---|
Grid |
gridLayout | Grid used for layout. |
Game |
brushTarget | Target of the erase operation. By default the currently selected GameObject. |
Vector3Int | position | The coordinates of the cell to erase data from. |
Overrides
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 |
---|---|---|
Grid |
flip | Axis to flip by. |
Grid |
layout | Cell Layout for flipping. |
Overrides
FloodFill(GridLayout, GameObject, Vector3Int)
This is not supported but it should flood-fill 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 |
---|---|---|
Grid |
gridLayout | Grid used for layout. |
Game |
brushTarget | Target of the flood fill operation. By default the currently selected GameObject. |
Vector3Int | position | Starting position of the flood fill. |
Overrides
GetCellIndex(int, int, int)
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 |
---|---|---|
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 cell index for the position of the BrushCell. |
GetCellIndex(int, int, int, int, int, int)
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 |
---|---|---|
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 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 |
---|---|
int | The cell index for the position of the BrushCell. |
GetCellIndexWrapAround(int, int, int)
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 |
---|---|---|
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 cell index for the position of the BrushCell. |
GetHashCode()
Hashes the contents of the brush.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code of the brush |
Overrides
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 |
---|---|---|
Grid |
gridLayout | Grid used for layout. |
Game |
brushTarget | Target of the move operation. By default the currently selected GameObject. |
Bounds |
position | Position where the move operation has ended. |
Overrides
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 |
---|---|---|
Grid |
gridLayout | Grid used for layout. |
Game |
brushTarget | Target of the move operation. By default the currently selected GameObject. |
Bounds |
position | Position where the move operation has started. |
Overrides
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 |
---|---|---|
Grid |
gridLayout | Grid used for layout. |
Game |
brushTarget | Target of the paint operation. By default the currently selected GameObject. |
Vector3Int | position | The coordinates of the cell to paint data to. |
Overrides
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 |
---|---|---|
Grid |
gridLayout | Grid to pick data from. |
Game |
brushTarget | Target of the picking operation. By default the currently selected GameObject. |
Bounds |
position | The coordinates of the cells to paint data from. |
Vector3Int | pivot | Pivot of the picking brush. |
Overrides
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 |
---|---|---|
Grid |
direction | Direction to rotate by. |
Grid |
layout | Cell Layout for rotating. |
Overrides
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. |
Game |
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. |