rgrams / debug-draw

A set of convenience functions for drawing debug lines, shapes, and text with Defold.
27 stars 2 forks source link

Any way this can work on the GUI space? #1

Open Blankeos opened 2 weeks ago

Blankeos commented 2 weeks ago

I know it draws on world space at the moment. Any way it can work in the GUI space? Would be useful to debug GUI-space coordinates. Thanks in advance!

Awesome work on this btw!

rgrams commented 1 week ago

Hmm, sort of. You can change it to screen space, by editing the render script. Simply move this line

render.draw_debug3d()

down to just below the GUI drawing functions. With the current default render script it would look like this:

render.draw(predicates.gui, camera_gui.frustum)
render.draw(predicates.debug_text, camera_gui.frustum)
render.draw_debug3d()

However, this is just absolute coordinates within the window, it won't have all the scaling stuff that GUI coordinates have. Also, it will break the physics debug drawing, since that's done in the same .draw_debug3d() call (both 2D and 3D).

If you are having trouble with GUI coordinates then it's probably better to just add some extra nodes to use for debugging. Their actual position and size will depend on their adjust mode.