#Understanding @tool scripts with child nodes

1 messages · Page 1 of 1 (latest)

dull spindle
#

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)

#

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?

bleak bone
solemn fiber
#

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.

dull spindle
#

yeah a little fiddling around worked

#

thanks for the help

mystic saddle