-
Notifications
You must be signed in to change notification settings - Fork 1
3.5 ‐ 06 Tooled scripts
Tooled scripts are executed in the editor, making it useful to both debug and create elements in the a scene without having to run the entire scene or game. Applications can go from a simple print of variable to a whole editor extension, are convenient for designing interfaces, drawing trajectories and simulate results based on editor values changes.
godot.set_script_tooled(Class:ClassName, bool);
In GDScript, this keyword is used at the beginning of the script
@tool
var myvar = 10
export var myEditorValue = 20
func _ready():
print("This will print on scene load")
With JavaScript, it's a godot method that registers the class as tooled
with godot.set_script_tooled
, meaning you can have code before and after registering the class
export default class MyClass extends godot.Node {
constructor() {
this.myvar = 10;
}
_ready() {
console.log("This will print on scene load");
}
}
godot.set_script_tooled(MyClass, true);
godot.register_property(MyClass, "myEditorValue", 20);
Unfortunately the hot-reload feature is not supported, any tooled
script must be reloaded by clicking the Scene > Reload saved scene
button. The script will still work as the last loaded version but any changes on the tooled
script requires a refreshed scene to apply changes.