Thank you!
The onready var is_ready = true
suggestion does not seem to work in tool mode (the variable has no value: not true, not false... just null).
I tried the call_deferred
too.
The new test code:
tool
extends Node2D
export(NodePath) var path setget setPath, getPath
func getPath():
return path
func setPath(newPath):
print("setPath()")
path = newPath
call_deferred("set_my_path")
func set_my_path():
print("set_my_path()")
Output 1 (when I select a node):
setPath()
set_my_path()
The functions called as I expected.
Output 2 (save scene without any modifications):
setPath()
The set_my_path()
was not called.
Output 3 (save scene, afler I changed anything in the code... ie: empty line then save)
setPath()
setPath()
set_my_path()
The setPath()
called twice, and the set_my_path()
called once...
I still don't know what is happening here exactly, but I just realized maybe it doesn't matter.
(Is there a detailed description somewhere?)
Now I think, that the set_my_path()
(via call_deferred
) is called only, if something has changed (in this case the has_node()
also works perfectly).
This information is actually enough for me.
What do you think?