Immediate Mode Question

Avatar
  • updated
  • Answered

When using immediate mode like below, I have a question:



[ExecuteAlways] public class MyScript : ImmediateModeShapeDrawer {

public override void DrawShapes( Camera cam ){

//...

}

}

 It seemed like when I put a script using Immediate Mode on more than one Game Object in the scene it only worked on one of them.

For instance, if a script with immediate mode drawing was on 5 game objects, it only drew it once.  But then if I put an immediate mode script on just one Game Object and make that script draw many shapes it's fine. Is that the correct way to use immediate mode? Should there only be one instance of a script drawing in immediate mode?

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

If you want to get as much performance out of it as possible, ideally you should use only one shape drawer

however, it does support using multiple ones. One thing to keep in mind is that by default, immediate mode shape drawer doesn't draw in local space, it draws in world space. so if you add this script to multiple objects, they will all draw in the same spot unless you explicitly set Draw.Matrix to the transform's matrix. But if that's not the issue then there's likely a bug happening!

Avatar
Freya Holmér creator
  • Answer
  • Answered

If you want to get as much performance out of it as possible, ideally you should use only one shape drawer

however, it does support using multiple ones. One thing to keep in mind is that by default, immediate mode shape drawer doesn't draw in local space, it draws in world space. so if you add this script to multiple objects, they will all draw in the same spot unless you explicitly set Draw.Matrix to the transform's matrix. But if that's not the issue then there's likely a bug happening!