https://blog.csdn.net/cartzhang/article/details/82764433
https://blog.csdn.net/luofeixiongsix/article/details/79966989
https://blog.csdn.net/shidya/article/details/71553360
https://docs.unrealengine.com/en-us/Programming/Assets/Registry
UWorld* PersistentWorld = GetWorld();
if (!PersistentWorld)
{
UE_LOG(LogTemp, Fatal, TEXT("UDynamicLevels::LoadTileToStreamingArray >> Invalid PersistentWorld!!!"));
return;
}
//new StreamingClass Instance 新流关卡实例
UClass* StreamingClass = ULevelStreamingKismet::StaticClass();
ULevelStreaming* StreamingLevel = Cast
// FName PackageName = TEXT("/Game/TempUmap/Level_01") 根据项目实际情况获取并设置PackageName
StreamingLevel->SetWorldAssetByPackageName(PackageName);
//Make New Level Visible 使流关卡可见
StreamingLevel->bShouldBeLoaded = true;
StreamingLevel->bShouldBeVisible = true;
StreamingLevel->bShouldBlockOnLoad = false;
//Very Important, used by LevelStreaming* to load the map 设置流关卡的包名
StreamingLevel->PackageNameToLoad = PackageName;
//Add to UWorld 将流关卡添加到World中
PersistentWorld->StreamingLevels.Add(StreamingLevel);
void AEngineTestActor::WorldSettings()
{
EditorWorld = InitWorld();
EditorWorld->GetWorldSettings()->bEnableWorldComposition = true;
EditorWorld->GetWorldSettings()->bEnableAISystem = true;
EditorWorld->GetWorldSettings()->bEnableHierarchicalLODSystem = true;
FStreamableManager& Streamable = UAssetManager::GetStreamableManager();
FSoftObjectPath AssetRef = FSoftObjectPath(TEXT("Blueprint'/Game/MyLODSetup.MyLODSetup'"));
TSoftClassPtr
EditorWorld->GetWorldSettings()->HLODSetupAsset = LODAsset;
ShowFcopeTask(FText::FromString(TEXT("PreviewBuild")));
EditorWorld->HierarchicalLODBuilder->ClearHLODs();
EditorWorld->HierarchicalLODBuilder->PreviewBuild();
ShowFcopeTask(FText::FromString(TEXT("BuildMeshesForLODActors")));
EditorWorld->HierarchicalLODBuilder->BuildMeshesForLODActors(true);
}
UWorld * AEngineTestActor::InitWorld()
{
check(GEngine);
UWorld* World = nullptr;
for (const FWorldContext& Context : GEngine->GetWorldContexts())
{
UWorld* ThisWorld = Context.World();
if (!ThisWorld || (Context.WorldType == EWorldType::PIE))
{
continue;
}
else if (Context.WorldType == EWorldType::Editor)
{
World = ThisWorld;
}
}
//
return World;
}