Operating system or device - Godot version:
3.x I guess
Idea
Just an idea but I think it's worth discussing.
I think it might be useful to export method in from a node so it would show up as a button in the inspector. Clicking the button would run exported method. Script using such feature would have to use tool
keyword of course.
I saw @kubecz3k have been using setgets in his Finite State Machine plugin for similar behavior - you can write state name into exported string and then setget handles creation of the state (or something like that, I haven't read the code yet). I think my idea is cleaner approach for tools working in editor.
Example
tool
extends Node2D
export var something = "foo"
export my_func "Create Foo" # function name, button text
func my_func(): # no parameters!
# do something
# no return, runs purely for side effects
Downsides
I'm not sure if inspector is good place to that kind of functionality. On the other hand writing editor plugin that adds few buttons to toolbar seems to be overkill to me. As an alternative to my idea I'd suggest putting exported functions/buttons in the toolbar when the node is selected - editor would handle adding/removing button automatically.
What do you think?
This is interesting, and would allow fixing a few current problems in
exposed stuff.
it's probably possible to do this in the inspector, but exporting a method
is a lot of work.
I suggest adding it as an export hint for boolean object. If you want, in
GDScript, you can do
export bool MyButton setget yourmethodtocall
On Sun, Jun 25, 2017 at 8:09 PM, Daniel Lewan notifications@github.com
wrote:
Operating system or device - Godot version:
3.x I guessIdea
Just an idea but I think it's worth discussing.
I think it might be useful to export method in from a node so it would
show up as a button in the inspector. Clicking the button would run
exported method. Script using such feature would have to use tool keyword
of course.I saw @kubecz3k https://github.com/kubecz3k have been using setgets in
his Finite State Machine plugin for similar behavior - you can write state
name into exported string and then setget handles creation of the state (or
something like that, I haven't read the code yet). I think my idea is
cleaner approach for tools working in editor.Example
toolextends Node2Dexport var something = "foo"export my_func "Create Foo" # function name, button text
func my_func(): # no parameters!
# do something
# no return, runs purely for side effects[image: insp-bttn-mckp]
https://user-images.githubusercontent.com/4397533/27520350-aac40f76-5a09-11e7-9f4e-072a874b17b1.pngDownsides
I'm not sure if inspector is good place to that kind of functionality. On
the other hand writing editor plugin that adds few buttons to toolbar seems
to be overkill to me. As an alternative to my idea I'd suggest putting
exported functions/buttons in the toolbar when the node is selected -
editor would handle adding/removing button automatically.
[image: mkp2]
https://user-images.githubusercontent.com/4397533/27520387-ffd88f2c-5a0a-11e7-8749-3941b850a81a.pngWhat do you think?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/9380, or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z29iLwmm2E_0RePjMGyRlHGg3kUZYks5sHuiwgaJpZM4OEwJ7
.
How would actions like this fit with undo/redo?
That sounds handy for "quick'n dirty" tooling, but on the long run I would use EditorPlugin for this tbh.
they probably dont, but I can imagine this is mostly used for computing
internal states or stuff like that, where it's not very relevant
On Mon, Jun 26, 2017 at 8:34 AM, Marc notifications@github.com wrote:
How would actions like this fit with undo/redo?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/9380#issuecomment-311034383,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z29dG-tvFQDZg_ltScx2SjxrCqRTVks5sH5dagaJpZM4OEwJ7
.
Perhaps something more like a parameter for the export function that just causes the bool's representation in the inspector to become a ToolButton rather than a CheckButton?
export(bool, TOOL_BUTTON) var create_foo setget on_create_foo_button_pressed
func on_create_foo_button_pressed():
# do stuff
As mentioned, until inspector is rewritten after 3.0, this will not happen..
On Oct 25, 2017 6:25 PM, "Will Nations" notifications@github.com wrote:
Perhaps something more like a parameter for the export function that just
causes the bool's representation in the inspector to become a ToolButton
rather than a CheckButton?
export(bool, TOOL_BUTTON) var create_foo setget on_create_foo_button_pressed
func on_create_foo_button_pressed():
# do stuff
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/9380#issuecomment-339476486,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z2wgQxs8zoL7kOKGI5Q9nqX8PtFcbks5sv6dHgaJpZM4OEwJ7
.
I'm really waiting for something like this one, I want to create a generate map button, like I have in my unity version, in unity, we can override some inspector methods, like draw and OnInspectorGUI (when something change in inspector), maybe we could have a way to override inspector and include buttons, fields, and things like we can in unity.
What's the status of this issue? As @maikramer mentioned, such feature is useful in regenerating the map inside editor. It's doable as editor plugin but it's needed as node's properties
@ShrewdSpirit There isn't a built-in way to do this without using an EditorInspectorPlugin from one's own EditorPlugin, for now. In my godot-next repository, I've created an EditorInspectorPlugin that delegates the task of creating the Inspector GUI additions to the object being edited in the Inspector, so you can now just add methods to a script to make stuff show up in that class's Inspector. We also have utilities to assist with this for buttons via our InspectorControls class. For example...
extends Node
func _parse_begin(p_inspector_plugin):
p_inspector_plugin.add_custom_control(InspectorControls.new_button("Generate Map", false, self, "_on_generate_map")
func _on_generate_map():
pass # generate the map
If people like the idea, I can discuss the idea of porting our DelegationInspectorPlugin (which enables this functionality) to the Godot Editor. I just haven't considered porting it cause I figured reduz had a reason not to include the functionality this way in the first place.
@willnationsdev The idea of what you've done is interesting. I'll try your method
Any update on this? Unity's editor tools are very powerful. Not having this in Godot is rather disappointing
@thorlucas It seems nobody has started working on this feature yet. As a workaround, you can use a boolean exported property that has a setget
method that will run a method when set to true
(without actually changing the property's value).
I bet you could probably write an EditorInspectorPlugin that could do something like this. Have it get the edited object, iterate through its list of methods, and then, based on a name convention (since annotations aren't supported yet), generate GUI elements in the Inspector such as a button, and then program that button to execute the method if pressed. So, it would be more about having magic methods that generate it (for now).
Annotation sounds better for a short form 🧙
@inspector_button
func say_hello():
print("Hello! Follow me")
As a shortcut for [Insert all the EditorInspectorPlugin stuff to do in order to have a button in the inspector to call a script method]
Annotations would be nice for GDScript, I use C# which already supports annotations. GDScript ought to have them too!
@thorlucas Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.
Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.
The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.
If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!
Most helpful comment
Annotation sounds better for a short form 🧙
As a shortcut for [Insert all the EditorInspectorPlugin stuff to do in order to have a button in the inspector to call a script method]