I couldn’t delete or edit this post. here’s the good one. Sorry.
I couldn’t delete or edit this post. here’s the good one. Sorry.
I have a struct called FMyGameSomeStruct that becomes a member of an Actor.
e.i.
UCLASS()
class MYGAME_API AMyGameActor: public AActor
{
GENERATED_BODY()
protected:
/** Struct that can be modified on instance from engine. */
UPROPERTY(EditInstanceOnly, BlueprintReadonly)
FMyGameSomeStruct SomeStruct;
}
Is there an equivalent of an Actors OnConstruction()
method for structs that can be use for a structs calculated properties? This way when the property is modified within the engine, it reconstructs the struct and recalculates these properties?
e.i.
if I have a struct defined like this:
MyGameSomeStruct.h
// This a property of an actor
USTRUCT(Blueprintable)
struct MYGAME_API FMyGameSomeStruct
{
GENERATED_USTRUCT_BODY()
/** Set from editor from an actor that instantiates this.*/
UPROPERTY(EditInstanceOnly)
int SomeNumber;
/** Calculated propery. Should be recalculated when SomeNumber is changed. */
UPROPERTY(BlueprintReadonly)
int SomeNumberTimesTen;
FMyGameSomeStruct();
}
MyGameSomeStruct.cpp
FTTWeatherActorSettings::FTTWeatherActorSettings():
SomeNumber(0),
SomeNumberTimesTen(0)
{
// This should be recalculated when `SomeNumber` is modified from the engine.
SomeNumberTimesTen = SomeNumber * 10;
}
// Is there something like this but for structs?
void FTTWeatherActorSettings::OnConstruction()
{
SomeNumberTimesTen = SomeNumber * 10;
}