-
Notifications
You must be signed in to change notification settings - Fork 372
Description
The title is pretty self-explanatory, but I'll include an example as well. This also concerns the collision layer of a TiledMapRenderer.
Suppose I have a map with the following layers:

And I load that map as the following:
var mapEntity = CreateEntity("map");
var map = Content.LoadTiledMap(Nez.Content.TiledAssets.Maps.RoomTest);
var tiledMapRenderer = mapEntity.AddComponent(new TiledMapRenderer(map, "Terrain"));
tiledMapRenderer.SetLayersToRender("Terrain", "TerrainBg");In this situation, the call to the TiledMapRenderer constructor will throw an exception because the Terrain layer is nested within the Level group layer. This can be fixed by passing null and manually setting the CollisionLayer field on the next line:
tiledMapRenderer.CollisionLayer = map.Groups["Level"].TileLayers["Terrain"];Even though this is not an optimal solution, it works. However, when selecting which layers to render with SetLayersToRender (or SetLayerToRender), I don't think there is a solution to this problem. The reason is that you can only set either top-level layer names or top-level layer indices.
I am very new to the framework, so I might've missed something while looking for a way to fix this.
I will soon create a pull request to add a way to do this; I'm currently working on it.