Null TileBase[] from a non-empty tilemap.

I am working on a 2D Isometric game based on TileMaps and I have this bug:

BoundsInt unlockedArea = temp.unlockedArea;
        BoundsInt buildingArea = temp.area;

        TileBase[] checkIfUnlockedArray = availableLandTileMap.GetTilesBlock(buildingArea);
        TileBase[] baseArray = mainTileMap.GetTilesBlock(buildingArea);

After running this code baseArray[ ] is filled with correct tiles from mainTileMap.
And checkIfUnlockedArray[ ] is filled with nulls - and that’s the problem. The buildingArea on this Tilemap consists of tiles that have been put there by the same script earlier on. These tiles are visible in Scene view in Unity.

However, if I put the same tiles in the same place manually before running the game (using Tile Palette) everything works as expected, the array is filled with the tiles.

I don’t understand what is the problem, since everything on the mainTileMap is detected as it should be (no matter if it was placed in-game or in editor).

Has anyone encountered this or have any ideas what might be causing it?

This is just return array full of nulls… availableLandTileMap.GetTilesBlock(buildingArea) If you need find your bug you should look in GetTilesBlock method.This is your own method or you using someones api?

GetTilesBlock is from Unity Scripting API:
https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.GetTilesBlock.html

Then you must have incorect setup in your editor. I bet there is no bug in this.

Yes, I agree that it does not seem like a bug, it’s more likely to be something I missed when programming, but at this point (after a few hours trying to understand what is going on) I am not sure anymore.
Here is a screenshot from Unity:


The right tilemap is assigned to the script and also you can see, that this tilemap has tiles all over it.
Debugger still shows that availableLandTileMap.GetTilesBlock(buildingArea); returns a TileBase array (size 49, as expected) but filled with nulls.

Is there something else that I am missing?

I found the root of the problem.

This line was the perpetrator:
temp.unlockedArea.position = gridLayout.WorldToCell(temp.gameObject.transform.position) + new Vector3Int(-25, -25, 1);

unlockedArea was simply on a different Z coordinate compared to the rest. It should have been:
temp.unlockedArea.position = gridLayout.WorldToCell(temp.gameObject.transform.position) + new Vector3Int(-25, -25, 0);

Thanks to MartinMa_BStudio for encouraging me to look for the mistake I made, instead of blaming it on Unity.