Fix PIE crash by loading test-world meshes at runtime instead of via ConstructorHelpers.
FObjectFinder is only valid in constructors; BuildTestWorld now uses LoadObject during BeginPlay. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
3c7fa78912
commit
e1ac8547b5
@ -12,7 +12,6 @@
|
||||
#include "Components/SkyLightComponent.h"
|
||||
#include "EngineUtils.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "UObject/ConstructorHelpers.h"
|
||||
|
||||
AVocationTestWorldBuilder::AVocationTestWorldBuilder()
|
||||
{
|
||||
@ -36,15 +35,15 @@ void AVocationTestWorldBuilder::BuildTestWorld()
|
||||
return;
|
||||
}
|
||||
|
||||
static ConstructorHelpers::FObjectFinder<UStaticMesh> PlaneMesh(TEXT("/Engine/BasicShapes/Plane.Plane"));
|
||||
if (PlaneMesh.Succeeded())
|
||||
UStaticMesh* PlaneMesh = LoadObject<UStaticMesh>(nullptr, TEXT("/Engine/BasicShapes/Plane.Plane"));
|
||||
if (PlaneMesh)
|
||||
{
|
||||
FActorSpawnParameters SpawnParams;
|
||||
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
|
||||
if (AStaticMeshActor* Floor = World->SpawnActor<AStaticMeshActor>(FVector::ZeroVector, FRotator::ZeroRotator, SpawnParams))
|
||||
{
|
||||
Floor->GetStaticMeshComponent()->SetStaticMesh(PlaneMesh.Object);
|
||||
Floor->GetStaticMeshComponent()->SetStaticMesh(PlaneMesh);
|
||||
Floor->SetActorScale3D(FVector(20.f, 20.f, 1.f));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user