Class GridBrushEditor
Editor for GridBrush.
Inherited Members
Namespace: UnityEditor .Tilemaps
Assembly: Unity.2D.Tilemap.Editor.dll
Syntax
[MovedFrom(true, "UnityEditor", "UnityEditor", null)]
[CustomEditor(typeof(GridBrush))]
public class GridBrushEditor : GridBrushEditorBase
Properties
brush
The GridBrush that is the target for this editor.
Declaration
public GridBrush brush { get; }
Property Value
Type | Description |
---|---|
Grid |
canChangeZPosition
Whether the GridBrush can change Z Position.
Declaration
public override bool canChangeZPosition { get; set; }
Property Value
Type | Description |
---|---|
bool |
Overrides
icon
Returns an icon identifying the Grid Brush.
Declaration
public override Texture2D icon { get; }
Property Value
Type | Description |
---|---|
Texture2D |
Overrides
shouldSaveBrushForSelection
Whether the Brush is in a state that should be saved for selection.
Declaration
public override bool shouldSaveBrushForSelection { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
tooltip
Describes the usage of the GridBrush.
Declaration
public override string tooltip { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
validTargets
Returns all valid targets that the brush can edit.
Declaration
public override GameObject[] validTargets { get; }
Property Value
Type | Description |
---|---|
Game |
Overrides
Remarks
Valid targets for the GridBrush are any GameObjects with a Tilemap component.
Methods
BoxFillPreview(GridLayout, GameObject, BoundsInt)
Does a preview of what happens when a GridBrush.BoxFill is done with the same parameters.
Declaration
public virtual void BoxFillPreview(GridLayout gridLayout, GameObject brushTarget, BoundsInt position)
Parameters
Type | Name | Description |
---|---|---|
Grid |
gridLayout | Grid to box fill data to. |
Game |
brushTarget | Target of box fill operation. By default the currently selected GameObject. |
Bounds |
position | The bounds to box fill data to. |
ClearPreview()
Clears any preview drawn previously by the GridBrushEditor.
Declaration
public virtual void ClearPreview()
ErasePreview(GridLayout, GameObject, Vector3Int)
Displays a preview of the Tile (after erasure) on the cell of a grid at the given coordinates of the cell.
Declaration
public virtual void ErasePreview(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
Parameters
Type | Name | Description |
---|---|---|
Grid |
gridLayout | The grid to paint data to. |
Game |
brushTarget | The target of the erase operation. This is the currently selected GameObject by default. |
Vector3Int | position | The coordinates of the cell to paint data to. |
Remarks
The GridBrush will paint preview Sprites of the Tiles (after erasure) into its brush cells on an associated Tilemap. This will not instantiate objects associated with the painted Tiles.
FloodFillPreview(GridLayout, GameObject, Vector3Int)
Does a preview of what happens when a GridBrush.FloodFill is done with the same parameters.
Declaration
public virtual void FloodFillPreview(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
Parameters
Type | Name | Description |
---|---|---|
Grid |
gridLayout | Grid to paint data to. |
Game |
brushTarget | Target of the flood fill operation. By default the currently selected GameObject. |
Vector3Int | position | The coordinates of the cell to flood fill data to. |
OnDisable()
Deinitialises the GridBrushEditor.
Declaration
protected virtual void OnDisable()
OnEnable()
Initializes the GridBrushEditor.
Declaration
protected virtual void OnEnable()
OnMouseLeave()
Callback when the mouse cursor leaves and editing area.
Declaration
public override void OnMouseLeave()
Overrides
Remarks
Cleans up brush previews.
OnPaintSceneGUI(GridLayout, GameObject, BoundsInt, Tool, bool)
Callback for painting the GUI for the GridBrush in the Scene View.
Declaration
public override void OnPaintSceneGUI(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing)
Parameters
Type | Name | Description |
---|---|---|
Grid |
gridLayout | Grid that the brush is being used on. |
Game |
brushTarget | Target of the GridBrushBase::ref::Tool operation. By default the currently selected GameObject. |
Bounds |
position | Current selected location of the brush. |
Grid |
tool | Current GridBrushBase::ref::Tool selected. |
bool | executing | Whether brush is being used. |
Overrides
OnSelectionInspectorGUI()
Callback for drawing the Inspector GUI when there is an active GridSelection made in a Tilemap.
Declaration
public override void OnSelectionInspectorGUI()
Overrides
OnToolDeactivated(Tool)
Callback when the GridBrush Tool is deactivated.
Declaration
public override void OnToolDeactivated(GridBrushBase.Tool tool)
Parameters
Type | Name | Description |
---|---|---|
Grid |
tool | GridBrush Tool that is deactivated. |
Overrides
Remarks
Cleans up brush previews.
PaintPreview(GridLayout, GameObject, Vector3Int)
Paints preview data into a cell of a grid given the coordinates of the cell.
Declaration
public virtual void PaintPreview(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
Parameters
Type | Name | Description |
---|---|---|
Grid |
gridLayout | The grid to paint data to. |
Game |
brushTarget | The target of the paint operation. This is the currently selected GameObject by default. |
Vector3Int | position | The coordinates of the cell to paint data to. |
Remarks
The GridBrush will paint preview Sprites in its brush cells onto an associated Tilemap. This will not instantiate objects associated with the painted Tiles.
RegisterUndo(GameObject, Tool)
Callback for registering an Undo action before the GridBrushBase does the current GridBrushBase::ref::Tool action.
Declaration
public override void RegisterUndo(GameObject brushTarget, GridBrushBase.Tool tool)
Parameters
Type | Name | Description |
---|---|---|
Game |
brushTarget | Target of the GridBrushBase::ref::Tool operation. By default the currently selected GameObject. |
Grid |
tool | Current GridBrushBase::ref::Tool selected. |
Overrides
Remarks
Implement this for any special Undo behaviours when a brush is used.
RenderStaticPreview(string, Object[], int, int)
Creates a static preview of the GridBrush with its current selection.
Declaration
public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
string | assetPath | The asset to operate on. |
Object[] | subAssets | An array of all Assets at assetPath. |
int | width | Width of the created texture. |
int | height | Height of the created texture. |
Returns
Type | Description |
---|---|
Texture2D | Generated texture or null. |