I saw that post and used yaustars method to remove a layer.
Yaustars code:
this.newlayer = this.app.scene.layers.getLayerByName('New');
this.layers = this.cameraEntity.camera.layers.splice(0);
var index = this.layers.indexOf(this.newlayer.id);
this.layers.splice(index, 1);
this.cameraEntity.camera.layers = this.layers;
My code:
const redSquare = this.app.root.findByName('Front');
let layers = redSquare.element.layers.splice(0);
const newLayer = this.app.scene.layers.getLayerByName('Front')
var index = layers.indexOf(newLayer.id);
layers.splice(index, 1);
redSquare.element.layers = layers;
The difference is that Yaustar is removing the layer from the camera entity resulting in all entities which have the specific layer to not be visible.
I keep the layer on the camera entity, as in my main project file I need other entities which have the specific layer to be visible while hiding just one (the one i am removing the layer of).
In the sample project I shared, I reconstructed the issue in a very simple setup.
I understand. In the shared topic there seems to be a problem with removing the layer from the camera component. Maybe the same problem occurs when you try to remove a layer from another component. As far I understand the workaround is to disable the entity, then change the layers and after that enable the entity again.
Hmm, after you’ve changed the element’s layers, you could probably reassign the camera layers to camera, without changing them. I think that should trigger a refresh.
The layers did in fact change on my element however the overlay entity had the wrong layer assigned. This resulted in the red square to still show in front.