Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Painting tiles on tilemap from prefab by script

Discussion in 'Prefabs' started by M3ME5, Oct 8, 2019.

  1. M3ME5

    M3ME5

    Joined:
    Sep 18, 2019
    Posts:
    2
    I am trying to paint my prefabs in my Tilemap. I created the prefabs by creating an empty object so it has the "Transform" in the inspector. When I do the following:
    Code (CSharp):
    1. Tile newBuildingTile = Instantiate(Resources.Load("Prefabs/" + buildingSpriteName + "Prefab")) as Tile;
    2.  
    3. mainTileMap.SetTile(currentCellMap, newBuildingTile);
    It doesn't paint the tile in the given position but at the prefabs preassigned x,y values.

    How do i fix this?