Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matheusmessora/425cbdfab455e574a93b822b37a46868 to your computer and use it in GitHub Desktop.
Save matheusmessora/425cbdfab455e574a93b822b37a46868 to your computer and use it in GitHub Desktop.
Unity Editor script to export Tilemaps (x,y) position
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Tilemaps;
[CustomEditor(typeof(Tilemap))]
public class CollisionsScript : Editor
{
private Tilemap tilemap { get { return (target as Tilemap); } }
public BoundsInt area;
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if(GUILayout.Button("EXPORT"))
{
Debug.Log("APERTOU");
BoundsInt bounds = tilemap.cellBounds;
TileBase[] allTiles = tilemap.GetTilesBlock(bounds);
for (int x = 0; x < bounds.size.x; x++)
{
for (int y = 0; y < bounds.size.y; y++)
{
TileBase tile = allTiles[x + y * bounds.size.x];
if (tile != null)
{
Debug.Log("x:" + x + " y:" + y + " tile:" + tile.name);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment