I want to understand how to use @tool
I set up a quick @tool script to streamline making walls in my game. It has 3 sprite nodes as children, which represent both edges and the fill in the middle. I set it up so that when I modify an @export variable, the wall will stretch accordingly. The problem is, I don't have access to the sprite variables since I'm running it in the editor. This is the code: (left, right and fill are the sprite nodes)
#Understanding @tool scripts with child nodes
1 messages · Page 1 of 1 (latest)
I tried attaching a @tool script to the sprites. Basically just a blank script with
@tool
extends Sprite2D
But it didn't do anything. What's the correct approach here?
The tool script can access native properties of its children. But idk if it can access Script based properties, like your own defined variables (unless the children are also tools)
You might need to restart your editor to have the expected functionality, can't really explain why but it's what works for me. Anything else and my tool scripts are always wonky. My best guess is the _init and _ready aren't called right after adding in the @tool annotation and the editor restart handles it
As for accessing child nodes that aren't tool scripts, usually that is fine in my experience.
just have to reload the scene