Код: Выделить всё
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);
}
}
Код: Выделить всё
UPROPERTY(EditDefaultsOnly, Category = "References")
UStaticMesh * m_staticMesh;
Код: Выделить всё
ARollingBall::ARollingBall()
{
UStaticMeshComponent* sphere;
sphere = CreateDefaultSubobject(TEXT("ball"));
sphere->SetupAttachment(RootComponent);
if (m_staticMesh) {
sphere->SetStaticMesh(m_staticMesh);
}
}
Любые предложения о том, как реализовать вышеуказанную функцию должным образом оценены. Если вы знаете лучший способ избежать жесткого кодирования, дайте мне знать.
Подробнее здесь: https://stackoverflow.com/questions/665 ... ect-in-cpp
Мобильная версия