Hey Guys,
Lately was trying to get spline Information out of the World Partition Actors at Runtime and failed, or just any partitioned object that is not loaded is hard to get to, this is what i got currently:
{
if (!World) return;
FGraphEventRef Task = FFunctionGraphTask::CreateAndDispatchWhenReady([=]()
{
if (!World || !World->GetWorldPartition())
{
UE_LOG(LogTemp, Error, TEXT("World or WorldPartition is invalid!"));
return;
}
UWorldPartition* WorldPartition = World->GetWorldPartition();
if (!WorldPartition)
{
UE_LOG(LogTemp, Error, TEXT("Failed to get WorldPartition."));
return;
}
FWorldPartitionHelpers::FForEachActorWithLoadingParams Params;
Params.ActorClasses.Add(ALandscape::StaticClass());
Params.ActorClasses.Add(ALandscapeStreamingProxy::StaticClass());
Params.bKeepReferences = true;
FWorldPartitionHelpers::ForEachActorWithLoading(WorldPartition, [&](const FWorldPartitionActorDescInstance* ActorDescInstance) -> bool
{
AActor* LoadedActor = ActorDescInstance->GetActor(true, true);
if (!LoadedActor)
{
UE_LOG(LogTemp, Warning, TEXT("Failed to load actor from ActorDescInstance."));
return true;
}
UE_LOG(LogTemp, Error, TEXT("Loaded Actor: %s"), *LoadedActor->GetName());
return true;
}, Params);
}, TStatId(), nullptr, ENamedThreads::GameThread);
FTaskGraphInterface::Get().WaitUntilTaskCompletes(Task);
UE_LOG(LogTemp, Log, TEXT("Road Network Generated from Landscape Splines."));
}