docs.unity3d.com
    Show / Hide Table of Contents

    Class LineBrush

    This Brush helps draw lines of Tiles onto a Tilemap. Use this as an example to modify brush painting behaviour to making painting quicker with less actions.

    Inheritance
    Object
    GridBrush
    LineBrush
    Inherited Members
    UnityEditor.Tilemaps.GridBrush.Init(UnityEngine.Vector3Int)
    UnityEditor.Tilemaps.GridBrush.Init(UnityEngine.Vector3Int, UnityEngine.Vector3Int)
    UnityEditor.Tilemaps.GridBrush.Erase(UnityEngine.GridLayout, UnityEngine.GameObject, UnityEngine.Vector3Int)
    UnityEditor.Tilemaps.GridBrush.BoxFill(UnityEngine.GridLayout, UnityEngine.GameObject, UnityEngine.BoundsInt)
    UnityEditor.Tilemaps.GridBrush.BoxErase(UnityEngine.GridLayout, UnityEngine.GameObject, UnityEngine.BoundsInt)
    UnityEditor.Tilemaps.GridBrush.FloodFill(UnityEngine.GridLayout, UnityEngine.GameObject, UnityEngine.Vector3Int)
    UnityEditor.Tilemaps.GridBrush.Rotate(UnityEngine.GridBrushBase.RotationDirection, UnityEngine.GridLayout.CellLayout)
    UnityEditor.Tilemaps.GridBrush.Flip(UnityEngine.GridBrushBase.FlipAxis, UnityEngine.GridLayout.CellLayout)
    UnityEditor.Tilemaps.GridBrush.Pick(UnityEngine.GridLayout, UnityEngine.GameObject, UnityEngine.BoundsInt, UnityEngine.Vector3Int)
    GridBrush.Reset()
    UnityEditor.Tilemaps.GridBrush.UpdateSizeAndPivot(UnityEngine.Vector3Int, UnityEngine.Vector3Int)
    UnityEditor.Tilemaps.GridBrush.SetTile(UnityEngine.Vector3Int, UnityEngine.Tilemaps.TileBase)
    UnityEditor.Tilemaps.GridBrush.SetMatrix(UnityEngine.Vector3Int, UnityEngine.Matrix4x4)
    UnityEditor.Tilemaps.GridBrush.SetColor(UnityEngine.Vector3Int, UnityEngine.Color)
    UnityEditor.Tilemaps.GridBrush.GetCellIndex(UnityEngine.Vector3Int)
    GridBrush.GetCellIndex(Int32, Int32, Int32)
    GridBrush.GetCellIndex(Int32, Int32, Int32, Int32, Int32, Int32)
    GridBrush.GetCellIndexWrapAround(Int32, Int32, Int32)
    GridBrush.GetHashCode()
    GridBrush.size
    GridBrush.pivot
    GridBrush.cells
    GridBrush.cellCount
    UnityEditor.Tilemaps.GridBrush.canChangeZPosition
    Namespace: UnityEditor.Tilemaps
    Syntax
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@latest/index.html?subfolder=/manual/LineBrush.html")]
    [CustomGridBrush(true, false, false, "Line Brush")]
    public class LineBrush : GridBrush

    Fields

    fillGaps

    Ensures that there are orthogonal connections of Tiles from the start of the line to the end.

    Declaration
    public bool fillGaps
    Field Value
    Type Description
    Boolean

    lineStart

    The current starting point of the line.

    Declaration
    public Vector3Int lineStart
    Field Value
    Type Description
    Vector3Int

    lineStartActive

    Whether the Line Brush has started drawing a line.

    Declaration
    public bool lineStartActive
    Field Value
    Type Description
    Boolean

    Properties

    IsMoving

    Indicates whether the brush is currently moving something using the "Move selection with active brush" tool.

    Declaration
    public bool IsMoving { get; }
    Property Value
    Type Description
    Boolean

    Methods

    GetPointsOnLine(Vector2Int, Vector2Int)

    Gets an enumerable for all the cells directly between two points http://ericw.ca/notes/bresenhams-line-algorithm-in-csharp.html

    Declaration
    public static IEnumerable<Vector2Int> GetPointsOnLine(Vector2Int p1, Vector2Int p2)
    Parameters
    Type Name Description
    Vector2Int p1

    A starting point of a line

    Vector2Int p2

    An ending point of a line

    Returns
    Type Description
    IEnumerable<Vector2Int>

    Gets an enumerable for all the cells directly between two points

    GetPointsOnLine(Vector2Int, Vector2Int, Boolean)

    Enumerates all the points between the start and end position which are linked diagonally or orthogonally.

    Declaration
    public static IEnumerable<Vector2Int> GetPointsOnLine(Vector2Int startPos, Vector2Int endPos, bool fillGaps)
    Parameters
    Type Name Description
    Vector2Int startPos

    Start position of the line.

    Vector2Int endPos

    End position of the line.

    Boolean fillGaps

    Fills any gaps between the start and end position so that all points are linked only orthogonally.

    Returns
    Type Description
    IEnumerable<Vector2Int>

    Returns an IEnumerable which enumerates all the points between the start and end position which are linked diagonally or orthogonally.

    MoveEnd(GridLayout, GameObject, BoundsInt)

    Ends the movement of tiles and GameObjects to a given position within the selected layers.

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

    Grid used for layout.

    GameObject brushTarget

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

    BoundsInt position

    The coordinates of the cell to move data to.

    MoveStart(GridLayout, GameObject, BoundsInt)

    Starts the movement of tiles and GameObjects from a given position within the selected layers.

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

    Grid used for layout.

    GameObject brushTarget

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

    BoundsInt position

    The coordinates of the cell to move data from.

    Paint(GridLayout, GameObject, Vector3Int)

    Paints tiles and GameObjects into a given position within the selected layers. The LineBrush overrides this to provide line painting functionality. The first paint action sets the starting point of the line. The next paint action sets the ending point of the line and paints Tile from start to end.

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

    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.

    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