DmitriySalnikov / godot_debug_draw_3d

Draw 3D debug graphics and 2D overlays with this add-on.

Home Page:https://dd3d.dmitriysalnikov.ru/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request]: DebugDraw2D should be visible on 2D viewport too

JUSTCAMH opened this issue · comments

Feature description

Currently all the functions in DebugDraw2D draw to the 3D viewport, and don't show anything in the 2D viewport. As the class is called DebugDraw2D, I had expected these functions would be useful for my 2D game, but alas this is not the case, I can see it in 3D but not in 2D.

Implementation Ideas

Functions in DebugDraw2D should draw to both the 2D and 3D viewports, so that they can be viewed in both the 2D and 3D editor tabs.

Do you mean the 2d and 3d tabs in the editor?
If so, there's set_custom_canvas for that. But that would allow drawing exactly on the canvas node, not the overlay in the editor, although you could try to get a 2d viewport of the editor.


if DebugDraw2D.custom_canvas != EditorInterface.get_editor_viewport_2d().get_parent():
	DebugDraw2D.custom_canvas = EditorInterface.get_editor_viewport_2d().get_parent()
DebugDraw2D.set_text("test")

Ahh, that is what I meant, thanks! And I believe the answer is no, but is it possible to draw lines, circles and other guides in the 2D tab?

And I believe the answer is no, but is it possible to draw lines, circles and other guides in the 2D tab?

Not yet. The library was originally planned for 3d, so 2d wasn't a priority. Also currently I don't see support for this library from the community (but people use this library quite a bit) and I have no motivation right now to add support for 2d shapes.

Ok thanks, totally understandable!

For anyone else looking, godot actually has some really great built in tools for this in 2D: https://docs.godotengine.org/en/stable/tutorials/2d/custom_drawing_in_2d.html

Yes it does. But to do this, you need to create separate variables with states inside the class and use a _draw method.
Therefore, if I ever start working on adding 2D shapes to this library, then all the logic with _draw and separate variables will be hidden from the user and you will just need to call DebugDraw2D.draw_line(a, b, Color.RED).
But I'm not really sure yet how the camera behavior, zooming, and other things will be handled.