Skip to content
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

Expose PropertySelector to scripting #7635

Closed
nlupugla opened this issue Sep 9, 2023 · 4 comments · Fixed by godotengine/godot#81655
Closed

Expose PropertySelector to scripting #7635

nlupugla opened this issue Sep 9, 2023 · 4 comments · Fixed by godotengine/godot#81655

Comments

@nlupugla
Copy link

nlupugla commented Sep 9, 2023

Describe the project you are working on

An addon built with GDExtension that helps users create saving and loading systems for their games.

Describe the problem or limitation you are having in your project

I want to use the engine's PropertySelector dialog to provide a UI where users can select which properties of a given node they want to save/load.

I can imagine this dialog would be useful in other plugins/addons as well (although admittedly I can't think of a concrete example other than my own project mentioned above).

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Exposing PropertySelector to scripting will allow users to select which properties they want to save/load using a familiar UI; the same one used in AnimationPlayer and MultiplayerSynchronizer.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Simply expose the existing PropertySelector https://github.com/godotengine/godot/blob/master/editor/property_selector.h to scripting. See draft PR for proposed implementation: godotengine/godot#81488.

Edit: I received feedback that exposing PropertySelector directly is not a good idea because it couples the implementation with the API. Instead, it was recommended that I incorporate some of PropertySelector's functionality into EditorInterface. Here are my proposed additions to EditorInterface.

signal properties_selected(properties : Array[NodePath])

func popup_dialog_property_selector(variable : Variant, valid_types : Array[Variant.Type]) -> void

Note: emitting an Array[NodePath] instead of just a NodePath let's you infer that the dialog was canceled (by checking whether the array is empty) and also allows multiple properties to be selected in principle.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I looked into recreating the PropertySelector in GDExtension, but there is currently no built-in way to list all the properties of a non-object Variant (see #2344).

Is there a reason why this should be core and not an add-on in the asset library?

N/A

@raulsntos
Copy link
Member

@nlupugla
Copy link
Author

Very relevant proposal! Does the fact that this proposal exists and has a lot of support affect this proposal and it's PR at all? As in, should we favor a more general solution that exposes a bunch of editor classes, or is it okay to expose them piecemeal?

@AThousandShips
Copy link
Member

I can imagine this dialog would be useful in other plugins/addons as well (although admittedly I can't think of a concrete example other than my own project mentioned above).

This is kind of a crux here, exposing internal components is a major tying up of the functionality and interface of things, which has to have a very good reason

@nlupugla
Copy link
Author

I've edited the original post with a proposal for implementing PropertySelector via EditorInterface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants