How to prevent selection of objects (Tool script)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MCrafterzz

Hello, I’ve just started with Godot and I wonder if it’s possible to disable the selection of objects in the editor when the node with my tool script is selected? I want to place stuff when you left click on object. So for that to work I don’t want to select the object. Thanks

:bust_in_silhouette: Reply From: Zylann

I think this can be done through an EditorPlugin. If your tool is 2D, you would make the plugin handles() function return true for the type of node you edit, override the forward_canvas_gui_input function, and return true, which means “input got handled” by your plugin, so it won’t be used by others.
The same goes for 3D, with forward_spatial_gui_input.

Note that you should only return true for input that you want ONLY your plugin to handle, and return false for others, because it can cause other functionality of the editor to not respond.

A side effect of this, is that this can prevent some gizmos of your own node to be used, like the 3D one: Editor plugin receives mouse events even if the Spatial gizmo is being manipulated · Issue #17499 · godotengine/godot · GitHub