x

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"

How can I load/unload a sublevel(tile) in a world composition?

I want to load/unload tiles in a world composition called from a blutility function in editor mode (not ingame). In the picture below you can see the contextmenu for load/unload tiles. I want the same functionality via a blueprint function.

alt text

I tested UGameplayStatics::LoadStreamLevel / UGameplayStatics::UnloadStreamLevel in BlueprintFunctionLibrary in a sample project.

 void UMyBlueprintFunctionLibrary::LoadLevel(FName LevelName)
 {
     FLatentActionInfo info;
     info.CallbackTarget = 0;
     info.ExecutionFunction = FName("");
     info.Linkage = 0;
     info.UUID = 0;
 
     UGameplayStatics::LoadStreamLevel(GWorld->GetWorld(), LevelName, true, false, info);
 }
 
 void UMyBlueprintFunctionLibrary::LoadLevelEditor(FName LevelName)
 {
     FLatentActionInfo info;
     info.CallbackTarget = 0;
     info.ExecutionFunction = FName("");
     info.Linkage = 0;
     info.UUID = 0;
 
     UGameplayStatics::LoadStreamLevel(GEditor->GetEditorWorldContext().World(), LevelName, true, false, info);
 }

"LoadLevel" does work ingame but not in editor mode called from a blutility function.

"LoadLevelEditor" does not work at all and gives the error "LogLevel: Warning: Failed to find streaming level object associated with 'sub1'"

Is there any way to achieve the same result as clicking Load/Unload in the contextmenu?

Product Version: UE 4.21
Tags:
wc.jpg (76.4 kB)
more ▼

asked Feb 19 '19 at 03:11 PM in Blueprint Scripting

avatar image

JoePenuci
1 1 1

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

2 answers: sort voted first

You will need to look at using the functions:

UGameplayStatics::LoadStreamLevel UGameplayStatics::UnloadStreamLevel

If you are using them in C++, you may also need to add the header: #include "Kismet/GameplayStatics.h"

more ▼

answered Feb 19 '19 at 04:13 PM

avatar image

Dune
1.9k 53 40 200

avatar image JoePenuci Feb 20 '19 at 10:58 AM

I tried it and edited my question

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

UGameplayStatics class is meant for runtime code. If you'd like to manage levels in the editor, you need EditorLevelUtils.

In my implementation, I keep an array of level names in the form of presets, so the user can easily switch between level presets. Then I retrieve ULevelStreaming* from the world (method in custom World Settings) and pass it to EditorLevelUtils methods.

This is ready snipper for you :)

https://gist.github.com/DoctorErgot/c98aa7fcb7ef7548338e24d950b8667c

more ▼

answered Jun 17 '19 at 11:00 PM

avatar image

Doctor Ergot
265 15 28 38

(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