How to drop variables from inspector in plugin?

Godot Version

4.5.1

Question

I am creating a plugin. I want that it will edit a variable on a node. Right now I understand how to make through EditorInterface.get_selection(), but I have to select a node and keep selection, and it has to be specific variable name on every node that I want to edit. Can I somehow to make that I can drag and drop a @export variable from inspector to plugin, and plugin will edit this particular variable?

Describe what exactly you want to accomplish with this. Give a specific example / use case.

1 Like

You can check how drag and drop works in this demo:

When dragging anything in the editor the dragged data will be different. You can check the structure by doing something like this in your EditorPlugin script:

func _process(delta: float) -> void:
	if get_viewport().gui_is_dragging():
		print(get_viewport().gui_get_drag_data())

Once you know the structure of the data you can make Control._can_drop_data() return true in your plugin and implement Control._drop_data() as needed.