Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Is it possible to find all of a game's ULevels at runtime?

I'm using level streaming exhaustively to break my game into smaller Levels, which I know are of the ULevel class, but ULevel extends UObject, not AActor, so GetAllActorsOfClass won't work in this case- is there an alternative function in the API that can run from the persistent level to return a TList of every single level in the game?

Product Version: UE 4.8
more ▼

asked Jul 23 '15 at 12:16 AM in C++ Programming

avatar image

266 97 67 83

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You can use TObjectIterator to iterate for any arbitrary class of object in memory. However, that does have some performance implications so use wisely.

With that said, you can use GetWorld()->GetLevels() to return you the list of levels

more ▼

answered Jul 23 '15 at 07:22 PM

avatar image

joeGraf STAFF
1.5k 35 12 69

avatar image HInoue Jul 23 '15 at 08:47 PM

Ooh, thank you! Am I implementing it correctly here? This looks right to me, but unreal crashes every time I try to compile it:

TArray levelList; levelList = GetWorld()->GetLevels();

avatar image HInoue Jul 23 '15 at 08:55 PM

Ack, I'm an idiot, it was crashing because I was running it in the class constructor before the world was finished instantiating. It works now, but it only returns the levels that are currently loaded- is there a way to run it once, and get every single level in the game, loaded and unloaded?

avatar image joeGraf STAFF Jul 23 '15 at 09:04 PM

I believe there is a way to use the AssetRegistry to find unloaded content of a particular type. I know that some of the tools do that when presenting lists of maps to cook, etc. I am not familiar with that code, but there are examples of how to do that in the engine. You'll just have to dig around a bit

avatar image HInoue Jul 23 '15 at 09:09 PM

Sounds good! Thank you very much for the help :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question