Make the C# tool script reloading process easier to work with
### Describe the project you are working on A colony survival/resource management game in C# with a lot of custom tooling ### Describe the problem or limitation you are having in your project The way data is reloaded into C# tool scripts after an assembly reload (e.g. after a recompilation) currently causes a lot of small annoyances that need to be worked around. Also, the specifics of data reloading are not documented which makes the behavior hard to predict unless you read the Godot source code. I'll describe the problems I've experienced one by one. ### 1. The parameter-less constructor of tool scripts is called after every compilation Every time you recompile your project, already instantiated tool scripts' parameter-less constructor is called. This is ok if your script doesn't do anything in its constructor or just sets initial data that doesn't rely on anything. However, if your constructor has side-effects, e.g. like adding a child node, this becomes a problem. ```csharp [Tool] public partial class MyToolScript : Node { public MyToolScript() { // This will be executed after every recompilation, probably not what you want/expect AddChild(new Node()); } } ``` The solution here is to never have side-effects in your parameter-less constructor. However, it can be limiting and it's easy to forget. ### 2. Tool scripts that don't have a parameter-less constructor can't be reloaded If your tool script doesn't have a parameter-less construct
Posted by ershn on Feb 1, 2024, 2:37 AM
Tags
Related issues
- To be fair, Inform7 can't succeed, generally, because there is no market for the kind of games that you create with Inform7.
- > The notion that somehow LR reliability is misunderstood by Consumer Reports, JD Power, Car & Driver, Automobile etc.
- Custom trigger IDs are not displayed in the new 2026.10 trigger selector
- I hate that too, but I think it’s more the ux than the concept of a default.
- > The biggest problem with UX developers is they know better than you AND force you into their paradigm.
- "Focus follows mouse" is what I use to keep the file manager from popping up when click-dragging files.
Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments
ux (Other)
To be fair, Inform7 can't succeed, generally, because there is no market for the kind of games that you create with Inform7.
New> The notion that somehow LR reliability is misunderstood by Consumer Reports, JD Power, Car & Driver, Automobile etc.
Custom trigger IDs are not displayed in the new 2026.10 trigger selector
I hate that too, but I think it’s more the ux than the concept of a default.
> The biggest problem with UX developers is they know better than you AND force you into their paradigm.
"Focus follows mouse" is what I use to keep the file manager from popping up when click-dragging files.
The biggest problem with this is if the target URL doesn't load but also doesn't quickly error out, like e.g.
Google wants to build up a private web here.
Make the C# tool script reloading process easier to work with
### Describe the project you are working on A colony survival/resource management game in C# with a lot of custom tooling ### Describe the problem or limitation you are having in your project The way data is reloaded into C# tool scripts after an assembly reload (e.g. after a recompilation) currently causes a lot of small annoyances that need to be worked around. Also, the specifics of data reloading are not documented which makes the behavior hard to predict unless you read the Godot source code. I'll describe the problems I've experienced one by one. ### 1. The parameter-less constructor of tool scripts is called after every compilation Every time you recompile your project, already instantiated tool scripts' parameter-less constructor is called. This is ok if your script doesn't do anything in its constructor or just sets initial data that doesn't rely on anything. However, if your constructor has side-effects, e.g. like adding a child node, this becomes a problem. ```csharp [Tool] public partial class MyToolScript : Node { public MyToolScript() { // This will be executed after every recompilation, probably not what you want/expect AddChild(new Node()); } } ``` The solution here is to never have side-effects in your parameter-less constructor. However, it can be limiting and it's easy to forget. ### 2. Tool scripts that don't have a parameter-less constructor can't be reloaded If your tool script doesn't have a parameter-less construct
Comments (0)
No comments yet. Start the discussion.