-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inspector not running code in @tool
scripts until restart
#66381
Comments
Through further experimentation, I have found that removing the script from the node and adding it back gets it to work |
I was just about to post this for setters.
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.
|
On my side, with a reference (Marker2D) field, reopening the scene or re-adding the script doesn't fix the issue. The setter simply seems ignored. Even assert(false) will show nothing. This prevents me from calling Since the issue only happens with get/set and assigning field in the inspector, should we rename the issue to something like "Inspector not running property get/set when reading/assigning field"? EDIT: actually I just read about parse_begin / parse_end also failing in the original post, and I've just tested _process and |
I tested again with a numeric property, and it worked this time. Warning was removed / appears in one second. @export var waypoint: Marker2D:
set(value):
waypoint = value
update_configuration_warnings()
@export var arrival_margin: float = 5.0:
set(value):
arrival_margin = value
update_configuration_warnings()
func _get_configuration_warnings() -> PackedStringArray:
var warnings:PackedStringArray = []
warnings.append_array(super._get_configuration_warnings())
if waypoint == null:
# this is always entered, as if waypoint node was not ready
warnings.append("Waypoint must be set")
if arrival_margin < 0:
# this is only called when actually the case
warnings.append("arrival_margin %s is negative" % arrival_margin)
return warnings One explanation could be that this is executed while iterating over the tree in a certain order, and referenced nodes are not ready yet (debugging showed that it was the case in _ready indeed, but I don't see why it would be when assigning a field in the middle of working in the editor). |
In my case the set action does work while the game itself is running and that it does not work when the game is not running
|
Also seeing this issue: I'm unable to run scripts in the editor via @tool. Following the official docs' tutorial on @tool verbatim doesn't work. |
IMO, I think this is a high priority feature to get working. Without editor scripting working, procedural generation is a total "guess and check" operation. |
@Mietzsche81 what specifically is not working, is it different from what's already mentioned here? Because running scripts in the editor does work in general |
Yes, to clarify: I am not able to run scripts in the editor in general. I have tried closing/reopening the scene and still can't even get the tutorial's rotation behavior to work. |
Have you restarted the editor? |
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 |
@AThousandShips huge thanks, that did the trick. In case it's helpful to anyone: When adding/removing After 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. |
@AThousandShips lots of people been running into this, really ought to be documented !!! |
Agreed, if an issue over it can't be find someone please open one (I'm preoccupied at the moment) |
@tool
scripts until restart
See also:
|
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? |
@YuriSizov I believe I can confirm this is still happening in 4.2-rc.2, though the behavior I'm seeing might not quite be the same. Also I'm using C#.
This Tool script will only run when the main scene is opened, and not the secondary scene. Restarting Godot enables it to run in both scenes. |
Can confirm the bug still exists on 4.2 also with GDScript. |
Bump happening to me as well on v4.3.dev5.official [89f70e9] |
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
tester
property in the inspector:Expected:
Value of
tester
to be set to half the input value. "NEW VALUE" should appear in the output logResult:
Value of
tester
is set to exactly the input value. No change in output logMinimal reproduction project
ToolBug.zip
The text was updated successfully, but these errors were encountered: