Topic was automatically imported from the old Question2Answer platform.
Asked By
d2clon
I come from Unity, and there you can use ContextMenu method attribute. It will add a button in the editor you can click and the method in your script will be invoked.
This is very helpful for testing/debugging purposes. When you are testing a functionality and you want an easy way to trigger it.
Is there something similar in Godot, or any workaround I can use?
Everytime you make changes to the scene there are cases where you
will need to reload so Save Scene then Reload Saved Scene
The _script_changed() function circumvents that to some degree but
only for changes made to the script itself and you should do things
like variable initialization there
Any exportable variable resource can be used to update the scene when changed
as demonstrated above
To use select Node > Attach Script > Select Template
Thanks for the detailed explanation. This helps a lot to make the game run in editor mode. And this may be very helpful for many scenarios.
In my case, I don’t need to run the whole game in the editor. What I need is to run the game normally in the run window. And then trigger a method of one of my scripts from a custom editor button. Just for testing/debugging purposes. For this method only.
Now that I am writing this, maybe the easiest way is to put a button into the game and catch the click on it. In Godot is insanely easy to add a button and then remove it. So maybe this is the way to go.
d2clon | 2022-12-10 15:17
Wait wait wait.
Hold the phone… You want to
run the game normally in the run window. And then trigger a method of one of my scripts from a custom editor button.
In that case in Debug enable Debug > Synchronize Scene Changes Debug > Synchronize Script Changes
And whenever you save the game gets updated
Not entirely sure but believe Godot links the editor and game window through some kind of network (most likely localhost) find which port the above question would be easily solved