godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Toggleable "show non exported properties" for EditorInterface.popup_property_selector , would solve several issues related to MultiplayerSynchronizer #10593

Open neth392 opened 2 weeks ago

neth392 commented 2 weeks ago

Describe the project you are working on

I'm working on a JSON serialization library that will work very similarly to the MultiplayerSynchronizer in terms of property selection. I use EditorInterface.popup_property_selector(...) to let the user select which properties they would like to be serialized.

Describe the problem or limitation you are having in your project

EditorInterface.popup_property_selector() only shows properties that have the PROPERTY_USAGE_EDITOR based on this if statement https://github.com/godotengine/godot/blob/fd7239cfab228c50777cd54a8bf6eb279a02ef81/editor/property_selector.cpp#L145-L147

This is an issue because many properties that should be serialized ideally shouldn't be shown in the editor. They can be but it could lead to confusion amongst teams working on a project, not realizing that property shouldn't actually be edited in the editor. The same goes for MultiplayerSynchronizer; some properties that are synchronized shouldn't be shown in the editor.

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

A CheckButton at the top of the PropertySelector popup that will toggle showing non exported properties. To my knowledge this should work with MultiplayerSynchronizer as well, resolving issues such as below:

https://github.com/godotengine/godot/issues/68516 https://github.com/godotengine/godot-proposals/issues/8662

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

Adding a CheckButton to the PropertySelector, and changing this if statement to detect if the CheckButton is toggled or not before excluding non-exported properties

https://github.com/godotengine/godot/blob/fd7239cfab228c50777cd54a8bf6eb279a02ef81/editor/property_selector.cpp#L145-L147

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

No

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

Not possible to create in an addon without creating an entirely new PropertySelector replica, and it still wouldn't integrate with MultiplayerSynchronizer

KoBeWi commented 2 weeks ago

There is @export_storage for serializing without showing in the inspector.

neth392 commented 1 week ago

@KoBeWi I'm writing my own serialization library for JSON, not using godot's resources as there is that well known security vulnerability when loading resources. I wanted to use the property selector popup to select properties to be serialized, for my use case. That popup only shows properties with "PROPERTY_USAGE_EDITOR". @export_storage adds the flag PROPERTY_USAGE_STORAGE, so those properties won't shop up.

I mentioned Multiplayer Synchronizer because there are other issues open that relate to non-editor properties not displaying in the property selector for it; the same property selector I wanted to use for my own different case.

But due to the limitation I've since pivoted to a different method of property selection, however I still think letting the popup from EditorInterface.popup_property_selector() show non-editor properties could be beneficial to many.