Describe the project you are working on:
Nothing particular
Describe the problem or limitation you are having in your project:
When tagging an script as tool, every single function inside of it will run in the editor, so if we want to have a single function to work in the Editor we need to put barriers on every other function at the start
if get_tree().is_editor_hint(): return
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
The proposal is to allow to put the tool keyword in front of functions which you want to allow execution during the editor
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
tool func set_texture(p_texture):
# Only this function runs in editor
if has_node("icon"):
$icon.texture = p_texture
If this enhancement will not be used often, can it be worked around with a few lines of script?:
The workaround is make the entire script a tool script and add barriers in functions you don麓t want to use, or implement only the editor functions in a separate script and then inherit that script with a no tool script. This is not possible if you already need to extend a different script (as multiple inheritance is forbidden (and for good reasons)
Is there a reason why this should be core and not an add-on in the asset library?:
It requiere changes on core (Script class) and GdScript module
Additionally, tool_only would be a useful keyword.
tool func foo() would run in the editor _and_ the running scene.
tool_only func bar() would run _only_ in the editor.
Consider also the old proposal in https://github.com/godotengine/godot/issues/8735#issuecomment-306916657.
Most helpful comment
Additionally,
tool_onlywould be a useful keyword.tool func foo()would run in the editor _and_ the running scene.tool_only func bar()would run _only_ in the editor.