Issue with image + graphics + depth + container

Hi guys, I was struggling with a little issue and playing around testing it and I’m not sure that should be the behaviour or I’m missing something…

Target: try to render a graphics below an image in a container

Case 1 (without container)

  • Render an Image
  • Render a graphics
  • Set graphics depth to be below image
  • It works as expected

Case 2

  • Create a container
  • Render an image
  • Render a graphics
  • Set graphics depth to be below image
  • Add graphics and image to the container
  • It doesn’t work with the depth

Case 3

  • Create a container
  • Render a graphics FIRST
  • Render an image
  • Add graphics and image to the container
  • It works as workaround

Here is a fiddle to play
https://jsfiddle.net/fxht9vow/
(removing “container.add” lines it works as expected)

I feel a bit confused with the behaviour, some light on this would be appreciated.

I have found that it happens even with any GameObjects…
The only way I found to deal with this apparently is…

container.addAt(gameObject, index)
4 Likes