Draw order of Immediate-Mode is very strange.

Avatar
  • updated
  • Answered

For multiply GameObject with Custom Shape(use Immediate-Mode Drawing), It seems draw order is not base on hierarchy, but is base on order of creation.

If I create GameObject like:

go1

go2

go3

then draw order is:

go3

go2

go1

and then,no matter how you change the order in hieracrchy,the draw order is not changed.

My temporary solution is to create gameObjects based on the drawing order.

Bbut, is there a better way.

It that possible by use Draw.Ztest? Can you give a concrete example?

Reporting a bug? please specify Unity version:
2021.1.15f1c1
Reporting a bug? please specify Shapes version:
4.0.2
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Answered

I've added some more detail now to the documentation on this to clarify how it works!

The ImmediateModeShapeDrawer component will subscribe to Unity's beginCameraRendering event in OnEnable

  • As a result, the order of separate IM shape drawers, depend on the order they were enabled in
  • You can explicitly set drawing order by either enabling the objects in a specific order, or changing script execution order in Unity, however...
  • ...I recommend having only one central ImmediateModeShapeDrawer in your scene, then have that call functions in other


Rread more here: https://www.acegikmo.com/shapes/docs/#draw-order

Avatar
Fan Applelin

It happen both in normal gameobject and ui gameobject.

Avatar
Freya Holmér creator
  • Answer
  • Answered

I've added some more detail now to the documentation on this to clarify how it works!

The ImmediateModeShapeDrawer component will subscribe to Unity's beginCameraRendering event in OnEnable

  • As a result, the order of separate IM shape drawers, depend on the order they were enabled in
  • You can explicitly set drawing order by either enabling the objects in a specific order, or changing script execution order in Unity, however...
  • ...I recommend having only one central ImmediateModeShapeDrawer in your scene, then have that call functions in other


Rread more here: https://www.acegikmo.com/shapes/docs/#draw-order

Avatar
Fan Applelin
Quote from Freya Holmér

I've added some more detail now to the documentation on this to clarify how it works!

The ImmediateModeShapeDrawer component will subscribe to Unity's beginCameraRendering event in OnEnable

  • As a result, the order of separate IM shape drawers, depend on the order they were enabled in
  • You can explicitly set drawing order by either enabling the objects in a specific order, or changing script execution order in Unity, however...
  • ...I recommend having only one central ImmediateModeShapeDrawer in your scene, then have that call functions in other


Rread more here: https://www.acegikmo.com/shapes/docs/#draw-order

Yes, you are right!

I should only use one central ImmediateModeShapeDrawer for all drawing things.(It should be enough to meet my needs at the moment)