godot: Inspector not running code in `@tool` scripts until restart
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version
4.0 beta 1
System information
Windows 10, Vulkan desktop
Issue description
No script marked as @tool appears to be executing when it is expected by the inspector. Examples I have found are that the set/get functions of properties are not being called and the parse_begin / parse_end functions of inspector plugins are not being called.
Steps to reproduce
- Create a new Node3D scene
- Attach a script with the following code:
extends Node3D
@export var tester:int:
get:
return 100
set(value):
print("NEW VALUE ", value)
tester = value/2
- Select your node and change the
testerproperty in the inspector:
Expected:
Value of tester to be set to half the input value. “NEW VALUE” should appear in the output log
Result:
Value of tester is set to exactly the input value. No change in output log
Minimal reproduction project
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 9
- Comments: 20 (12 by maintainers)
Can confirm the bug still exists on 4.2 also with GDScript.
@AThousandShips lots of people been running into this, really ought to be documented !!!
@AThousandShips huge thanks, that did the trick.
In case it’s helpful to anyone:
When adding/removing
@toolfrom a script or attaching/detaching a@tooled script to a scene, you must restart the editor to add/remove interactivity in the editorAfter restarting, I’m now able to edit the script and see the behavior change immediately without having to restart the editor. But if I create a new scene and attach the same script to it, I have to restart the editor again to get the behavior into the process loop.
This is unfortunately a current limitation which I’m not sure why it is, nor is it documented, can’t find an issue tracking it either
This shouldn’t be a requirement. Attaching a script should just work, at most you need to reload the scene (especially for previously attached scripts). If this is not the case right now and you need to restart the whole editor, it’s not something to document but rather something to fix.
Importantly, though, does this still happen in 4.1.3 or 4.2 betas?
See also:
Have you restarted the editor?
I was just about to post this for setters. while work around for the
intsetter above does work, it doesn’t seem to even try, for anything that’s in the tree like aNode3D.everything but the Node3D prints whether you just open the scene or change the setting. this is of course only after closing and reopening the scene after adding the setter.
on run it does. though the Node3D setter fires later in order after other scripts have initialized. which I would assume is exactly right. ex:
Through further experimentation, I have found that removing the script from the node and adding it back gets it to work