I am using a grid in a 3D project so I changed the grid to XZY and the tilemap to XZ so the tiles would be horizontal instead of vertical and I wrote this script that should tell me the tile sprite:
public class From2DTo3D : MonoBehaviour
{
int rows = 100;
int cols = 100;
public Tilemap tilemap;
// Start is called before the first frame update
void Start()
{
Make3DMap();
}
// Update is called once per frame
void Update()
{
}
void Make3DMap()
{
for(int x = -100; x < rows; x++)
{
for(int z = -100; z < cols; z++)
{
if(tilemap.GetSprite(new Vector3Int(x, 0 , z)) != null)
{
Sprite sprite = tilemap.GetSprite(new Vector3Int(x , 0 , z));
print(x+ " , " + z + " " + sprite.name);
}
else if(tilemap.GetSprite(new Vector3Int(x, 0, z)) == null)
{
// print(x + " , " + z + " null");
}
}
}
}
The problem is it only tells the sprites of tiles with 0 in the Z axis and I don’t understand why…