The @tool annotation
As well as using GDScript to run code during our game’s execution, we can actually use it to run code in the editor itself. Running code within the editor grants us the power to visualize things, such as the jump height of a character, or automate our workflow. In doing so we extend the Godot editor for our own specific needs. There are multiple ways of running GDScript code within the editor, ranging from running separate scripts to writing whole plugins, but the easiest way is by using the @
tool
annotation.
The @tool
annotation is an annotation that can be added to the top of any script. Its effect is that nodes with that script will run their script within the editor as if they were instanced within a game. This means that all of their code runs from within the editor.
This is very useful when we are editing our scenes and want to preview things within the editor, such as the health of our player, or create new nodes using code.
Knowing this...