[Help] Getting all Sublevels of a Level

I’m looking online for a while and I can’t seem to find anything useful regarding this.

I have a Level with multiple sublevel in it, each of one set to Blueprint as Streaming Method. Is there a way to get any kind of reference to the sublevels before them being loaded?

I tried World::GetLevels() but I only get the persistent as it is the only one already loaded, I think.

Thank you very much for any help.


I found a workaround in this old post: How to change a sub level variable in level(persistent) blueprint - UE4 AnswerHub

In short, using the GetStreamingLevel node in combination with the right cast node will allow to know if a level is a sublevel of the current persistent, directly in Blueprint. It was what I needed to make my project work, but I wonder if there is a way to obtain a full list of Sublevels in C++. Any clue?

We use this code to show/hide a dedicated point cloud data steaming level. Might help you out:

 // iterate through streaming levels
 // show or hide the point cloud level based on current visibility
 const TArray<ULevelStreaming*>& streamedLevels = GetWorld()->GetStreamingLevels();
 for (ULevelStreaming* streamingLevel : streamedLevels)
  FString levelName = streamingLevel->GetWorldAssetPackageName();
  if (levelName.ToLower().Contains("pointcloud"))
   if (streamingLevel->IsLevelVisible())

You’ll need #include “Runtime/Engine/Classes/Engine/LevelStreaming.h”