UE4: "Add Existing Level" in the level browser now uses an asset picker when launching with -WorldAssets

[CL 2101920 by Bob Tellez in Main branch]
This commit is contained in:
Bob Tellez
2014-06-11 11:43:46 -04:00
committed by UnrealBot
parent 65ac9d0436
commit 77eb1f33b9
6 changed files with 98 additions and 3 deletions

View File

@@ -2073,4 +2073,40 @@ void FLevelCollectionViewModel::CacheCanExecuteSourceControlVars()
}
}
void FLevelCollectionViewModel::AddExistingLevelFromAssetPicker(const TArray<FAssetData>& SelectedAssets, EAssetTypeActivationMethod::Type ActivationType)
{
const bool bCorrectActivationMethod = (ActivationType == EAssetTypeActivationMethod::DoubleClicked || ActivationType == EAssetTypeActivationMethod::Opened);
if (SelectedAssets.Num() > 0 && bCorrectActivationMethod)
{
const FAssetData& AssetData = SelectedAssets[0];
if (AssetData.AssetClass == UWorld::StaticClass()->GetFName())
{
// Close the menu that we were picking from
FSlateApplication::Get().DismissAllMenus();
// Fire ULevel::LevelDirtiedEvent when falling out of scope.
FScopedLevelDirtied LevelDirtyCallback;
// Add the level
ULevel* NewLevel = EditorLevelUtils::AddLevelToWorld(CurrentWorld.Get(), *AssetData.PackageName.ToString(), AddedLevelStreamingClass);
if (NewLevel)
{
LevelDirtyCallback.Request();
}
// For safety
if (GEditorModeTools().IsModeActive(FBuiltinEditorModes::EM_Landscape))
{
GEditorModeTools().ActivateMode(FBuiltinEditorModes::EM_Default);
}
// refresh editor windows
FEditorDelegates::RefreshAllBrowsers.Broadcast();
// Update volume actor visibility for each viewport since we loaded a level which could potentially contain volumes
GUnrealEd->UpdateVolumeActorVisibility(NULL);
}
}
}
#undef LOCTEXT_NAMESPACE