goostengine / goost

A general-purpose, extensible and customizable C++ extension for Godot Engine.
https://goostengine.github.io/
MIT License
481 stars 18 forks source link

Drawing using `Debug2D` overlays the editor when using `tool` script #163

Closed Xrayez closed 2 years ago

Xrayez commented 3 years ago

Goost and Godot version: ca9d585, Godot 3.4

OS/platform/device including version: Windows 10

Issue description: Drawing using Debug2D via tool script results in this:

image

Steps to reproduce:

tool
extends Node2D

func _process(delta):
    Debug2D.clear()
    Debug2D.draw_circle(64)

Not sure if possible to resolve for now, but I think it should be possible to instantiate Debug2D in the canvas item 2D viewport rather than editor (or rather, point Debug2D.canvas_item property to root node in the scene or so), otherwise this should be documented, and behavior prevented by not instantiating Debug2D singleton in the editor itself.

Xrayez commented 2 years ago

I made it work to draw stuff in the editor

image

This has a little quirk though: the drawing will persist across scenes if not cleared via script prior to that. Which is kind of expected since Debug2D operates globally. This might be a usability issue for some. In this case, perhaps adding some buttons to manually clear the debug draw canvas might be sufficient (or make an editor plugin to do this automatically). But again, drawing in the editor is not the primary use case for this feature, so I treat this as low priority.