Get Tilemap array

I think it useful to be able to get array of Tilemap, like:

  • Whole Tilemap
  • All sides (4 or 8) of specific tile

I’m tired of making maps with hard coding or soft coding. I want to make it with Tilemap.
I think it would be better to get array of script attached to Tile Asset.
cf. https://forum.unity.com/threads/feature-request-attach-script-to-tileasset.654559/

I could get where characters can go, distance of path, and so on.

Could you explain more about what you mean by this?

Right now, to get tiles around a particular position, you could try this:

var tiles = tilemap.GetTilesBlock(new BoundsInt(new Vector3Int(x -1, y - 1, z), new Vector3Int(3, 3, 1));

I’m sorry in a confusing representation. I’ll explain my problem frankly.
I have a huge array of numbers so I can store data of map.
When I modified the map, I have to modify the array too. That’s frustrating for me.
What should I do for this problem?

I am not certain of what you mean by this. Could you explain more?

I assume that when you modify the Tilemap, you need to modify an array of external data somewhere else? If so, is there a relation between this data and the Tilemap or the Tiles?

I mean, I wanna tell AI a map.

Here is a map, for example.
4484890--412870--image.png

This is an array storing data of the map(0 is ground, and 1 is wall).

int[,] map =
{
    { 1,1,1,1,1 },
    { 1,0,0,1,1 },
    { 1,1,0,0,1 },
    { 1,0,0,0,1 },
    { 1,1,1,1,1 },
};

If we have the array, AI can figure out where they can go(In this case, left side and down side).