Conditionals
Overview
Conditionals in MetaForge are used to control the visibility and editing capabilities of model object properties within the Unreal Engine editor. By using conditionals, developers can create dynamic and context-sensitive editor interfaces, ensuring that only the relevant properties are displayed or modified based on specific conditions.
Defining Conditionals
To use conditionals, you can annotate your model object properties using the If
metadata tag. This tag allows you to specify a condition, which is a Python expression evaluated against the properties of your object to determine whether a given property should be displayed in the editor.
The Python expression uses Python naming conventions, which can be a bit tricky at first. For example, Unreal-style property names like bEnableAdvancedSettings
must be written in snake_case (b_enable_advanced_settings
) in the Python condition.
It's important to convert Unreal's CamelCase or PascalCase property names to snake_case when writing conditions. Additionally, any properties used in conditionals must be marked as BlueprintReadWrite
to ensure they can be accessed and evaluated properly in the editor.
Example Code
Here is an example of using conditionals in a model object:
In this example:
bEnableAdvancedSettings
is a property that acts as part of the condition for displayingAdvancedSettingValue
. It must be marked asBlueprintReadWrite
to be used in a conditional.AdvancedSettingValue
is only displayed in the editor if the conditionbEnableAdvancedSettings
evaluates totrue
.
Use Cases for Conditionals
Advanced Settings: Show or hide advanced configuration options based on a simple checkbox or toggle.
Contextual Properties: Display properties only when certain conditions are met, such as the type of an object or the value of another property.
Simplified Editor Interface: Reduce clutter in the editor by hiding irrelevant properties until they are needed.
Best Practices for Conditionals
Use Clear Conditions: Ensure that the conditions used for hiding or showing properties are easily understandable and predictable for the user.
Avoid Overuse: Too many conditionals can make the editor interface confusing. Use them judiciously to improve the user experience.
Summary
Conditionals provide a powerful way to create context-sensitive and dynamic editor interfaces in MetaForge. By using conditionals, you can enhance the usability of your tools by showing only relevant information to the user, reducing clutter and making the editor experience more intuitive.
Last updated