๐งฑ Functional Structure
Short Description
The Functional Structure system enables FGorgeousFunctionalStructure_S- derived structs to receive PreEditChangeProperty and PostEditChangeProperty events in the Unreal Editor details panel, giving developers reactive control over structure property editing.
Long Description
By default, USTRUCT types in Unreal Engine cannot respond to property changes in the editor. The Functional Structure customization solves this by registering a custom IPropertyTypeCustomization that forwards property-change events to the struct instance.
This is particularly useful for:
- Validation: Reacting to changes and enforcing constraints in real-time.
- Dependent properties: Updating one field when another changes.
- Editor feedback: Showing warnings or computing derived values on edit.
๐ง How It Works
The FGorgeousFunctionalStructurePropertyTypeCustomization class implements IPropertyTypeCustomization and performs:
- Child iteration - Iterates all child properties, respecting
ShowOnlyInnerPropertiesmetadata (promotes grandchildren) andAdvancedDisplaygrouping (collapsed by default). - Event binding - Binds
PreEditChangeandPostEditChangedelegates to each child property. - Instance resolution - Extracts the
FGorgeousFunctionalStructure_S*pointer and callsAllocateDefaultValues()during customization.
Default Behavior
By default the editor does not handle ShowOnlyInnerProperties or AdvancedDisplay for struct properties. This customization implements both metadata features, allowing for more flexible struct layouts and better editor organization.
Functional Structures vs. Instanced Structs
Functional Structures are not the same as Instanced Structs. They are designed for editor interactivity, while Instanced Structs are for runtime polymorphism.
๐ Registration
Use the provided macros to register your struct for functional structure customization:
// In your module's StartupModule():
UE_DECLARE_FUNCTIONAL_STRUCTURES_REGISTER(FMyCustomStruct);
// In your module's ShutdownModule():
UE_DECLARE_FUNCTIONAL_STRUCTURES_UNREGISTER(FMyCustomStruct);
๐งฑ Creating a Functional Structure
Derive your struct from FGorgeousFunctionalStructure_S:
USTRUCT(BlueprintType)
struct FMyCustomStruct : public FGorgeousFunctionalStructure_S
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float Speed = 100.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float ComputedValue;
// Called when any property changes in the editor
virtual void PostEditChangeProperty(FPropertyChangedEvent& Event) override
{
Super::PostEditChangeProperty(Event);
// Recompute derived values
ComputedValue = Speed * 2.0f;
}
};
Editor to Runtime
Functional Structures are designed for in editor use only, but share their base struct with runtime code. The change events only fire during details panel editing, not at runtime.