Godot Version
4.1
Question
for example, when moving or manipulating nodes, there are output messages indicating property operations. I want to listen to such changes for editing games.
4.1
for example, when moving or manipulating nodes, there are output messages indicating property operations. I want to listen to such changes for editing games.
First, you need to create a plugin. Then you need to write @tool
above your script that controls your node.Then you can override the setter like this:
@tool
extends BaseClass
@export var my_var: Type:
set(value):
my_var = value
print(value)
You can listen to the property_changed
signal from a @tool
script and do as you please with the info it provides.
link: EditorProperty — Godot Engine (latest) documentation in English
Thank you for your response. However, EditorProperty
seems to be a signal for custom controls. How can I get the signal for property changes on default controls?
It is the same (base) class the actual editor uses. You can see this by checking the signals of the object in the panel like so:
@tool
extends Node
func _notification(what):
if what == NOTIFICATION_APPLICATION_FOCUS_IN:
for c in EditorInterface.get_inspector().get_child(0).get_children():
if c is Container:
for c2 in c.get_children():
if c2 is Container:
for c3 in c2.get_children():
for s in c3.get_signal_list():
print(s.name)
property_changed
will be there a few times
I’m sorry, I still can’t find a suitable solution. Could you demonstrate with code how to listen for changes in the position of an image node in the Godot editor within a plugin? Thank you very much.
Oh, for that just use the property_list_changed
on the Object
.
You can get what is selected from EditorInterface.get_selection()
.
I just assumed you were already doing this, sorry.
Dunno if is what you need. But i¡m using this to track properties changed in the inspector. property_edited It returns a property name, I use like this.
`EditorInterface.get_inspector().property_edited.connect( on_inspector_edited_object_changed, )
func on_inspector_edited_object_changed(prop):
print(prop)`
Thank you past chafalleiro
Thank you, this was exactly what I was looking for