Skip to content
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

Fix for Inspector not running code in @tool scripts until restart #92099

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Hilderin
Copy link
Contributor

@Hilderin Hilderin commented May 19, 2024

This PR should fix the problem where adding @tool in a GDScript where there are getters and setters does not work until the editor is restarted #66381.
I figured out that the problem was caused by creating a PlaceHolderInstance when the script is not a tool and nothing was converting it to a GDScriptInstance when adding @tool. The inverse was probably also a problem when removing the @tool.

It's my first time working with the GDScript, so I certainly missed something especially that my fix was real simple to implement. I did not test extensively.

I did not modify anything to fix the same issue with C# script. I'll wait your feedback before trying the same fix with C#.

@Hilderin Hilderin requested a review from a team as a code owner May 19, 2024 01:38
@Hilderin Hilderin force-pushed the fix_tool_script_not_running_until_restart branch from 8ba1180 to ef6e94d Compare May 19, 2024 02:19
@dalexeev dalexeev added this to the 4.3 milestone May 19, 2024
@Isabello
Copy link

Isabello commented Jul 4, 2024

is there any chance this actually makes it into 4.3? This is still a problem in the current beta

@KoBeWi KoBeWi modified the milestones: 4.3, 4.4 Jul 24, 2024
@KoBeWi KoBeWi added the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Jul 24, 2024
@AThousandShips AThousandShips changed the title Fix for Inspector not running code in @tool scripts until restart #66381 Fix for Inspector not running code in @tool scripts until restart Aug 8, 2024
@Hilderin Hilderin force-pushed the fix_tool_script_not_running_until_restart branch 3 times, most recently from db87af6 to 1e33ec9 Compare August 30, 2024 03:39
@Hilderin
Copy link
Contributor Author

I modified the code to prevent recalling reload_scripts on itself and fixing a problem where all the scripts received in parameters were reloaded in the loop.

@akien-mga akien-mga changed the title Fix for Inspector not running code in @tool scripts until restart Fix for Inspector not running code in @tool scripts until restart Aug 30, 2024
@Hilderin Hilderin force-pushed the fix_tool_script_not_running_until_restart branch 2 times, most recently from 334f999 to 3adf04c Compare August 30, 2024 10:57
@betalars
Copy link
Contributor

There is now also a MR to document the issue this MR aims to resolve.
Reminder to remove or rephrase that when this gets merged.

@Hilderin Hilderin force-pushed the fix_tool_script_not_running_until_restart branch from 3adf04c to 9a27a6f Compare January 23, 2025 20:42
@Hilderin
Copy link
Contributor Author

Just rebased to fix conflicts.

@Repiteo Repiteo added the cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release label Feb 24, 2025
@Repiteo Repiteo modified the milestones: 4.4, 4.5 Feb 24, 2025
@ryevdokimov
Copy link
Contributor

This needs a rebase, but from initial testing this seems to fix tool scripts from not doing anything at all when first attached until the scene is reloaded. From reading old issues this is something that worked in the past, except for process overrides since those are called on ready.

I have a branch built on top of this one that could be a solution for allowing tool scripts to run as soon as they are attached including the processes: https://github.com/Open-Industry-Project/godot/tree/tool-scripts-without-reloading-scene, ideally leading to a nice workflow of not having to reload the scene as often for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release topic:editor topic:gdscript
Projects
None yet
8 participants