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 do I load a level in a commandlet?

How do I load a map in a commandlet? I need to iterate over all levels in the world, and all actors in each level to export them in our custom format.

The following approaches do not work... (with various tweaks)

 UGameplayStatics::OpenLevel( GWorld, FName( "SunTemple" ), true );
 
 GEngine->LoadMap( *GEngine->GetWorldContextFromWorld( GWorld ), URL, nullptr, Error );
 
 GEngine->SetClientTravel( GWorld, TEXT( "?SunTemple" ), TRAVEL_Absolute );
 
 UPackage* Package = LoadPackage( nullptr, TEXT( "/Game/Maps/SunTemple.umap" ), LOAD_EditorOnly );
 
 GEditor->HandleMapCommand( TEXT( "LOAD FILE=" ), Ar, GWorld );

 FEditorFileUtils::LoadMap( TEXT( "/Game/Maps/SunTemple.umap" ) );

Any tips would be greatly appreciated!

Cheers John

Product Version: UE 4.18
Tags:
more ▼

asked Dec 07 '17 at 10:03 PM in C++ Programming

avatar image

PrimalJohnScott
6 2 3 6

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

2 answers: sort voted first

Hello John,

I hope that the following links will be useful https://docs.unrealengine.com/latest/INT/Programming/Assets/AsyncLoading/index.html https://answers.unrealengine.com/questions/134539/list-all-maps-in-project-or-directory.html

You can specify UWorld class in AssetRegistry::GetAssetsByClass or UObjectLibrary::CreateLibrary function

Sincerely,

Kostiantyn

more ▼

answered Feb 20 '18 at 01:49 PM

avatar image

K.Mostovyi
6 3

avatar image PrimalJohnScott Mar 30 '18 at 03:42 PM

This worked - thanks! How do I mark as resolved?

Cheers John

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

call this to load a world in the commandlet:

 UWorld * world = FAssetUtilityLibrary::LoadLevel(environment.GetUnrealMapPath());

call this to create a new world in the commandlet

 UWorld* NewWorld = UWorld::CreateWorld(EWorldType::None, false);


more ▼

answered Oct 11 '18 at 02:42 PM

avatar image

Mauxx91
21 1 2 6

(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