USTRUCT calculated property value

Hello forums.

I have a USTRUCT defined as below:



USTRUCT(BlueprintType)
struct Foo : public FTableRowBase
{
    GENERATED_BODY()

    UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
    float Value;

    /* Interest in percentage (value between 0.0 and 1.0) */
    UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, meta = (ClampMin = "0.0", ClampMax = "1.0", UIMin = "0.0", UIMax = "1.0"))
    float Interest;

    /* Total value including the interest */
    UPROPERTY(VisibleAnywhere)
    float TotalValue;
}


The property TotalValue should be automatically calculated (Value * (Interest + 1)) to display the value with interest. Can I write some custom getter for this property, and if so, how would I go about writing it? :slight_smile:

You can override PostEditChangeProperty() on object owner of Foo to calculate there value of Foo.TotalValue whenever Foo.Interest changed.