94{
95 bOutAlreadyLoaded = false;
96 bOutSuccess = false;
97
98 if (WorldContextObject == nullptr)
99 {
100 return nullptr;
101 }
102
103 UWorld* World = WorldContextObject->GetWorld();
104
105 if (World == nullptr)
106 {
107 return nullptr;
108 }
109
110 if (ULevelStreaming* ExistingLevel =
FindByName(World, LevelName))
111 {
112 bOutAlreadyLoaded = ExistingLevel->IsLevelLoaded();
113 bOutSuccess = true;
114 return ExistingLevel;
115 }
116
117 const FString TargetLevelName = LevelName.ToString();
118 ULevelStreamingDynamic* StreamingLevel = ULevelStreamingDynamic::LoadLevelInstance(WorldContextObject, TargetLevelName, FVector::ZeroVector, FRotator::ZeroRotator, bOutSuccess);
119 return StreamingLevel;
120}
static ULevelStreaming * FindByName(const UWorld *World, FName LevelName)
Definition LevelStreamingSubsystem.cpp:50