Within Blueprint, Construction Script is an event graph that runs any time a property is changed on the object it is attached to—whether from being dragged in the editor viewport or changed via direct entry in a Details panel.
Construction scripts allow the object in question to 'rebuild' itself based on its new location, for instance, or to change the components it contains based on user-selected options.
When coding in C++ with Unreal Engine, the equivalent concept is the OnConstruction
function.
Create a new
Actor
calledAOnConstructionActor
based onStaticMeshActor
.Add the following
UPROPERTY
to the class:UPROPERTY(EditAnywhere) bool ShowStaticMesh;
Add the following function definition:
virtual void OnConstruction(const FTransform& Transform) override;
Add the following to the class constructor:
auto MeshAsset = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/Engine/BasicShapes/Cone.Cone'")); if (MeshAsset...