Code: Select all
ARollingBall::ARollingBall()
{
UStaticMeshComponent* sphere;
sphere = CreateDefaultSubobject(TEXT("ball"));
static ConstructorHelpers::FObjectFinder SphereVisualAsset(TEXT("/Engine/BasicShapes/Sphere"));
sphere->SetupAttachment(RootComponent);
if (SphereVisualAsset.Succeeded()) {
sphere->SetStaticMesh(SphereVisualAsset.Object);
}
}
Code: Select all
UPROPERTY(EditDefaultsOnly, Category = "References")
UStaticMesh * m_staticMesh;
Code: Select all
ARollingBall::ARollingBall()
{
UStaticMeshComponent* sphere;
sphere = CreateDefaultSubobject(TEXT("ball"));
sphere->SetupAttachment(RootComponent);
if (m_staticMesh) {
sphere->SetStaticMesh(m_staticMesh);
}
}
Irgendwelche Vorschläge, wie die obige Funktion erstellt werden kann richtig geschätzt werden. Wenn Sie einen besseren Weg kennen, um Hardcodierungspfade zu vermeiden, lassen Sie es mich bitte wissen.