public virtual void PaintPreview(GridLayout gridLayout, GameObject brushTarget, Vector3Int position) { Vector3Int min = position - m_GridTileBrush.pivot; Vector3Int max = min + m_GridTileBrush.size; BoundsInt bounds = new BoundsInt(min, max - min); var pvmanager = PreviewManager.Instance; if (pvmanager == null) return; if (brushTarget != null && gridLayout != null) { foreach (Vector3Int location in bounds.allPositionsWithin) { Vector3Int brushPosition = location - min; TilePaletteGridTileBrush.BrushCell cell = m_GridTileBrush.cells[m_GridTileBrush.GetCellIndex(brushPosition)]; if (cell.gridTile != null) { SetPreviewCell(gridLayout, location, cell); } } } m_LastGrid = gridLayout; m_LastBounds = bounds; m_LastBrushTarget = brushTarget; m_LastTool = GridBrushBase.Tool.Paint; }
private static void SetPreviewCell(GridLayout grid, Vector3Int position, TilePaletteGridTileBrush.BrushCell cell) { if (cell.gridTile == null || grid == null) return; var pvmanager = PreviewManager.Instance; if (pvmanager == null) return; PreviewManager.Instance.InstantiatePreviewTileAtPosition(cell.gridTile, position.ToVector2IntXY(), cell.offset, cell.orientation); }
public virtual void BoxFillPreview(GridLayout gridLayout, GameObject brushTarget, BoundsInt position) { if (brushTarget != null) { var pvmanager = PreviewManager.Instance; if (pvmanager == null) return; foreach (Vector3Int location in position.allPositionsWithin) { Vector3Int local = location - position.min; TilePaletteGridTileBrush.BrushCell cell = m_GridTileBrush.cells[m_GridTileBrush.GetCellIndexWrapAround(local.x, local.y, local.z)]; if (cell.gridTile != null) { SetPreviewCell(gridLayout, location, cell); } } } m_LastGrid = gridLayout; m_LastBounds = position; m_LastBrushTarget = brushTarget; m_LastTool = GridBrushBase.Tool.Box; }