Replies: 1 comment
-
There's already a proposal open for this: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Feature Description:
The proposed feature introduces a new
@export_if
tag for GDScript (and potentially C#) that allows for conditional exporting of variables in the Godot editor. This tag would enable developers to hide or show specific exported variables in the editor based on a boolean condition.This is particularly useful when working with enumerations or toggle variables that determine which properties should be displayed. For example, if a property depends on an enum value, the
@export_if
tag would allow developers to conditionally export related properties, making the editor more intuitive and reducing clutter.How it Works:
@export_if(condition): Export the following variables only if the condition evaluates to
true
. The condition could reference an exported enum or boolean variable.@export_end: Marks the end of the block where the conditional export applies. All variables between
@export_if
and@export_end
will only be visible in the editor if the condition is met.Benefits:
Cleaner Editor Interface: Only show properties relevant to the current context, especially when using enums or feature toggles.
Improved Usability: Reduces confusion by hiding irrelevant properties based on user selections.
Flexibility: Can be applied in various contexts like enums, boolean toggles, or even custom conditions.
Motivation:
The current workarounds to achieve a similar behavior in the Godot editor are not practical and involve unnecessary complexity. These alternative approaches not only require way more code but also make the script harder to maintain and less intuitive to use.
By introducing the
@export_if
feature, developers can minimize redundant code and focus on the core logic of their game or application. This will improve usability for both new and experienced Godot developers, making the editor more adaptable and responsive to the needs of their projects.Example:
Now:
With This Feature:
Beta Was this translation helpful? Give feedback.
All reactions