Reputation: 1641
I am new to Unity, so please hang in there with me.
I am attempting to build an isometric tilemap object for my game's terrain. The tile imagery is stored in a binary file. I have bee reading through Unity's documentation on Isometric Tilemaps but it's not clear to me yet how I insert the tilemap imagery via a script.
Hoping someone here can outline how to go about this or point me at some helpful documentation.
If helpful, here is some light documentation on the binary file that I am parsing: https://uo.stratics.com/heptazane/fileformats.shtml#3.8
Upvotes: 0
Views: 803
Reputation: 914
Ifyou wanna set tile on (x,y) coordinates you can use Tilemap method SetTile (or change texture on return tile of method GetTile), for example:
//fields:
public Tilemap Map;
public TileBase[] TileTypes = { water, ground, mountain.....} //fill in the inspector (Texture2D/Sprite/Tile/Image/anything you want)
//array = world from your binary file (I use int but you can use anything you want)
public void GenerateTileMap (int[,] world)
{
for (int x = 0; x < world.GetLength(0); x++)
for (int y = 0; y < world.GetLength(1); y++)
Map.SetTile(new Vector3Int(x, y, 0), TileTypes[world[x, y]]);
}
Read more in scripting api reference (look at public methods): https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.html
Upvotes: 0