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