Using tool buttons remotely at runtime possible?

Godot Version

v4.5.1.stable.official [f62fdbde1]

Question

I an attempt to easily modify member variables of a node at runtime for debugging purposes without having to mess around with an Input system or extra UI Systems I’d have to implement, I attempted to use a tool button, which I tried to activate during runtime through the remote scene tree.

Here is the minimal setup I tried:

@tool
extends Node

@export_tool_button("Hello World", "Callable") var action: Callable = function

func function() -> void:
    print("Hello World")

It works fine in editor, but as soon as I play the scene, navigate to the remote scene tree, select the node in question and try pressing the button an error is thrown.
ERROR: Tool button action “null::null” is an invalid callable.

I suspect that it might be the expected behavior (tool buttons being meant for editor only), if so a confirmation would be nice.
If not why does this happen and how can this error be avoided?

As far as I know, yes, tool buttons are meant for editor only. But I can’t imagine it would be too difficult to simply add a button to the screen for your game yourself and use that to make anything you want happen.
Look into the command pattern for a nice and clean implementation.

That’s sad since it is also possible to change variables in the inspector… I will look into the software engineering pattern you mentioned and thanks for the confirmation.

1 Like