I have a button I can click which will wait for me to click in the 2D Scene View, it should then report where in the world I clicked.
Currently, I can get the screen position of the mouse, but not relative to the world. Not sure how to do this in the editor.
What I have so far:
func _forward_canvas_gui_input(event):
if will_get_world_coord:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
var scene = get_editor_interface().get_edited_scene_root()
# what to do here?
will_get_world_coord = false
getWorldCoordButton.set_pressed_no_signal(false)
return true
else:
return false
Note that, scene.getglobalmouse_position() returns 0,0.