Closed iRadEntertainment closed 8 months ago
Related to #2537.
This has been addressed by https://github.com/godotengine/godot/pull/75694 and https://github.com/godotengine/godot/pull/68696. The last link shows how to get the editor viewports, all 3d editor cameras, and the 2d transform.
@akien-mga
Closing per the above comment.
Describe the project you are working on
I'm making a plugin that is meant to scatter Sprites2D on a scene with a paint action.
Describe the problem or limitation you are having in your project
At the moment I can access an overlay via
forward_canvas_draw_over_viewport(overlay)
but I don't have a direct access to know the zoom of the main viewport, neither the position of the mouse in the actual scene.CanvasItemEditor
is not exposed to get any information from there so it is quite hard to scale a preview of my sprites according to the zoom of the viewport and getting the position of the mouse on the actual scene to manipulate (in this case to instantiate sprites and add them to a selected node)Describe the feature / enhancement and how it helps to overcome the problem or limitation
I suggest to expose
CanvasItemEditor
methods, or have an access to the global position of the mouse on the scene as well the zoom of the viewport, in order to draw on the overlay scaled accordingly.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The
CanvasItemEditor
could be passed as an argument viaforward_canvas_draw_over_viewport(overlay, canvasEditor)
CanvasItemEditor
may have getters like:canvasEditor.get_editor_vieport_zoom()
canvasEditor.get_editor_vieport_global_mouse_position()
If this enhancement will not be used often, can it be worked around with a few lines of script?
In order to do that now it's cumbersome, since a reference to an actual node in the scene is needed only to get to its transforms, like done here in GDQuest tutorial (https://www.youtube.com/watch?v=H6TfKYtuM9U&t=61s). Another hacky example could be found here: https://godotengine.org/qa/6369/how-to-get-the-editors-camera It doesn't seems that things have changed since 2016 when this question was posed by Zylann
Is there a reason why this should be core and not an add-on in the asset library?
I think so because it improves basic usability for the overlay used by
forward_canvas_draw_over_viewport(overlay)
without workarounds.