Question about depth

I’m currently working on a 2D RPG, and I just made a tilesheet for houses, so that they can be modular depending on how I need them, and I need some help deciding the best way to go about something.

In order to make certain parts render in front of others, (windows in front of walls, but behind roofs) I’ve got several tilemaps for the different layers of the house, and they’re all set to a different sorting order, which mostly works just fine.

The problem came in when I was trying to create depth, where if the player is in front of a house they render behind it, and if they’re in front, they render in front of it.

If I was making the houses one gameobject with a texture on it, I would just set its and the players Z value to the same thing as their Y value and have them on the same sorting layer, but that won’t work if I put a depth script on the tilemaps, because it would change the whole tilemap at once, so all houses would be at the same depth. Also there seems to be a problem where one tilemap with a higher Z than another doesn’t always render in front of it in 2D.

I could also put each house in its own gameobject under the grid, and have about 4 tilemaps per house, but that feels inefficient.

Does anyone know a good way to do this? Is that not actually as inefficient as I thought? Can I possibly make each individual tile have a Z value based on its world position? Do I need to completely rework the way I do houses?

Thanks in advance!

I know this is an old post, but the unity 2d extra’s (GitHub - Unity-Technologies/2d-extras: Fun 2D Stuff that we'd like to share!) has scriptable tiles. I think you could use these, but I’m not sure.