TileMap in custom layer doesn't render
Hi everybody.
I have an issue with multiple TileMaps in Unity 2D. I have a scene with ground, walls, and traps aligned on the same grid but in different tile maps to allow different collision behavior. Each of them has its own composite collider 2D. Previously they were all on the same layer, and I was differentiating them using tags, it was working just fine.
I tried to switch to using layers instead (as it seems to be the way to go). So I created new layers called "Ground", "Walls" and "Traps" and assigned each tile map to its layer. All of a sudden, walls and traps are not rendering. If put back in the Ground layer or the Default layer, they render correctly.
I made sure the sorting layers where fine, and they are. I tried reordering the layer differently, with no success. I'm out of ideas and can't find my answer on the internet. I feel it has to do with layers, but I'm not aware about them having an impact on rendering.
Does anyone have an idea about what's going on ? Feel free to ask any further information.
Thank you very much :)
Answer by sebjui · Feb 24, 2021 at 09:49 PM
Ok, I found what's going on. It turns out the new layers were not automatically added to the camera culling mask on creation. After adding them manually, everything is fine.
This is my first time messing with the camera's culling mask, but I feel like this should be automatic. I suspect this is due to the fact I have two cameras in my scene : each of them automatically removed the other from its culling mask, so the selection was not on "everything".