public static void GenerateBlockedCellGraphic(Grid overlayGrid, Grid gameWorldGrid) { var blockTile = Resources.Load <Tile>("Materials/TileMaps/Tiles/Grassland@128x128_17"); var tileMap = SetupTileMapObject(overlayGrid, "Blocked Cell Overlay", 3); tileMap.ClearAllTiles(); //get max bounds of the game world var currentBounds = Tilemapper.GetMaxBoundsOfGrid(gameWorldGrid); //set color of blockable layer var color = Color.red; color.a = 0.5f; var renderer = tileMap.GetComponent <TilemapRenderer>(); Material tileRenderMaterial = (Material)Resources.Load("Materials/TileRenderMaterial", typeof(Material)); renderer.material = tileRenderMaterial; renderer.material.color = color; for (var x = currentBounds.xMin - 1; x < currentBounds.xMax + 1; x++) { for (var y = currentBounds.yMin - 1; y < currentBounds.yMax + 1; y++) { if (!Tilemapper.IsGridPassableAtCoordinate(gameWorldGrid, new Vector2Int(x, y))) { tileMap.SetTile(new Vector3Int(x, y, 0), blockTile); } } } }
public static void GenerateGridCoordinateText(Grid overlayGrid, Grid gameWorldGrid) { var currentBounds = Tilemapper.GetMaxBoundsOfGrid(gameWorldGrid); for (var x = currentBounds.xMin - 1; x < currentBounds.xMax + 1; x++) { for (var y = currentBounds.yMin - 1; y < currentBounds.yMax + 1; y++) { var local = overlayGrid.CellToLocalInterpolated(new Vector3Int(x, y, 0)); local.z = -7; local.y += 1; var textGameObject = new GameObject("coord_text_" + x + "_" + y); textGameObject.transform.SetParent(overlayGrid.transform); var textMesh = textGameObject.AddComponent <TextMesh>(); textMesh.text = x + "," + y; Font textMeshFont = textMesh.font; textMesh.characterSize = 0.5f; textGameObject.transform.SetPositionAndRotation(local, Quaternion.identity); } } }