-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export method as button in inspector #9380
Comments
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 ***@***.***> wrote:
*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 <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.png>
*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.
[image: mkp2]
<https://user-images.githubusercontent.com/4397533/27520387-ffd88f2c-5a0a-11e7-8749-3941b850a81a.png>
What do you think?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9380>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF-Z29iLwmm2E_0RePjMGyRlHGg3kUZYks5sHuiwgaJpZM4OEwJ7>
.
|
How would actions like this fit with undo/redo? |
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 ***@***.***> 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
<#9380 (comment)>,
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?
|
As mentioned, until inspector is rewritten after 3.0, this will not happen..
On Oct 25, 2017 6:25 PM, "Will Nations" <[email protected]> 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
<#9380 (comment)>,
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...
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 |
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] |
This comment has been minimized.
This comment has been minimized.
@thorlucas Please don't bump issues without contributing significant new information. Use the 👍 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! |
Google took me to this issue. Did this have a new proposal opened that can be linked to? |
Not yet, but I can open one.
There's already a hack you can use using a boolean exported property: godotengine/godot-docs#4106 Given it's a hack, the PR above will probably not be merged. |
Yeah I'd prefer that we implement a proper way to export a toggle button that would be linked to a method, as it's a very useful feature and it would be worth serving properly with a supported method. |
umm no yet?? At the moment I use the hack( c#): |
Similar to Barrrettt;s post, I think this is a close gdscript equivalent
|
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
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?
The text was updated successfully, but these errors were encountered: