You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When editing a script to include @tool to reflect visual changes in a parent/sibling component, no changes are seen until I reload the project.
I have this simple script:
@toolextendsNode2D@exportvarsprite : Sprite2D@exportvarcolour : Color :
get:
returncolourset(value):
colour=valueifis_node_ready():
sprite.self_modulate=colour
The first time I add this script to a Node2D after writing it, and modify the colour - I don't see the colour of the sprite change until I reload the project. However, after reloading I can remove the script and re-add it to the same or a different node and it will continue to work. It's only the first time I try to use the script after writing it does the issue occur. Deleting the script, creating a new one, and pasting the exact same code in will also make the issue occur again.
Steps to reproduce
Create a new project with a Node2D as the root.
Add a Sprite, set to the default icon.svg.
Add a Node2D and attach a script to it.
Put this in the script:
@toolextendsNode2D@exportvarsprite : Sprite2D@exportvarcolour : Color :
get:
returncolourset(value):
colour=valueifis_node_ready():
sprite.self_modulate=colour
Drag Sprite into the exported field on the Node2D
Change the exported colour variable on the Node2D and see that it doesn't affect the sprite.
Go to Project > Reload Current Project
Change the colour variable again and see that it does now affect the sprite.
Additionally:
9. Detach the script from the node, and delete it.
10. Attach a new script to the node, add the same script.
11. Drag the sprite back into the field.
12. Change the colour, and it isn't affecting the sprite again.
Minimal reproduction project (MRP)
This is simple enough to recreate and given that it seems to depend on things being used/written for the first time I don't think it's necessary I provide a project.
The text was updated successfully, but these errors were encountered:
As far as I remember, it should be enough to restart only the scene, not the whole editor. For resources, you may need to restart the editor if the resource has many references and therefore will not be unloaded when you close a single scene.
My guess is that ScriptInstance is only created when a node is initialized, and it only happens when the script is @tool. Thus changing it after the node was initialized won't take effect.
btw, for draw() you can simply toggle visibility twice.
Tested versions
Tested in v4.2.2.stable.mono.official [15073af]
System information
Godot v4.2.2.stable.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 Ti (NVIDIA; 32.0.15.5585) - AMD Ryzen 7 5800X 8-Core Processor (16 Threads)
Issue description
When editing a script to include
@tool
to reflect visual changes in a parent/sibling component, no changes are seen until I reload the project.I have this simple script:
The first time I add this script to a Node2D after writing it, and modify the colour - I don't see the colour of the sprite change until I reload the project. However, after reloading I can remove the script and re-add it to the same or a different node and it will continue to work. It's only the first time I try to use the script after writing it does the issue occur. Deleting the script, creating a new one, and pasting the exact same code in will also make the issue occur again.
Steps to reproduce
Additionally:
9. Detach the script from the node, and delete it.
10. Attach a new script to the node, add the same script.
11. Drag the sprite back into the field.
12. Change the colour, and it isn't affecting the sprite again.
Minimal reproduction project (MRP)
This is simple enough to recreate and given that it seems to depend on things being used/written for the first time I don't think it's necessary I provide a project.
The text was updated successfully, but these errors were encountered: