๐Ÿงฑ 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:

  1. Child iteration - Iterates all child properties, respecting ShowOnlyInnerProperties metadata (promotes grandchildren) and AdvancedDisplay grouping (collapsed by default).
  2. Event binding - Binds PreEditChange and PostEditChange delegates to each child property.
  3. Instance resolution - Extracts the FGorgeousFunctionalStructure_S* pointer and calls AllocateDefaultValues() 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.