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

Add @export_editor for Inspector-only variables #11326

Open
Synzorasize opened this issue Dec 9, 2024 · 1 comment
Open

Add @export_editor for Inspector-only variables #11326

Synzorasize opened this issue Dec 9, 2024 · 1 comment

Comments

@Synzorasize
Copy link

Describe the project you are working on

A GUI RPG which uses custom Resources to store all the data, whereas Nodes are only used for the UI and to access these Resources. Some Resources are @tool scripts.

Describe the problem or limitation you are having in your project

I have variables that I edit in the Inspector to modify another variable with another type that is only stored. The setters for these variables never modify the variable itself, so it doesn't make sense to store these variables. For example, I might have a stored transform variable, so I would have setter variables position, rotation and scale that modifies transform. These variables also have getters that read transform and return information accordingly. Since these variables would not have the same type as transform (they would be Vector2/3, while transform would be Transform2/3D), I cannot use the same setters and getters for transform, and therefore can't be stored directly.

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

Having the @export_editor annotation would make it quick and easy to define these variables, without having to pass two default arguments in @export_custom just to access the third. It would improve readability as well. Also, when there is @export_storage, it makes sense to have this annotation, too, for consistency.

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

Just put @export_editor in front of the variable the same way you would put @export_storage.

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

@export_custom(PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), but it is incredibly verbose for simply having it appear in the Inspector without being serialized.

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

@export annotations are core, so it would be more intuitive this way.

@dalexeev
Copy link
Member

dalexeev commented Dec 9, 2024

The problem is that unlike @export_storage, there are many field appearance variations in the editor: not only @export, but also other @export_* annotations (@export_range, @export_multiline, etc.). So we will probably need to implement a separate modifier annotation that would remove the PROPERTY_USAGE_STORAGE flag. See #7794 (comment).

@export var a: String
@export @no_storage var b: String
@export_multiline var c: String
@export_multiline @no_storage var d: String

Alternatively, you could use _validate property() since editor-only fields imply tool mode.

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

No branches or pull requests

3 participants