Topic was automatically imported from the old Question2Answer platform.
Asked By
IvanVoirol
Hey,
I’m working on a pixel-art point and click, and I often have to place objects precisely (pixel-perfect) in the scenes, and I was wondering if there was a way to display the mouse cursor’s position (x and y) in the 2D editor.
It would save me a lot of time !
No, I don’t need the in-game position of the mouse, but the position of the mouse when using the editor, the same way you get the position of your cursor in the script editor in the bottom-right corner of the window.
There is a Ruler Mode (R). it can be used to measure distance and angles but when you click it will display the coordinates and it is the easiest solution I have found.
As of now, if you don’t want to make a plugin you can also put this in a tool script to show mouse position when clicked:
func _process(delta):
if Engine.is_editor_hint():
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
var mouse_pos = get_viewport().get_mouse_position()
print(mouse_pos)
Of course that can be changed to have some other conditional or none at all depending on your needs.