Change to "Create Child Blueprint Class" so that the new asset is created and set up for inline renaming in the Content Browser, instead of opening the Blueprint Editor with the default name.

#jira UE-11519 - Blueprints: RMB -> "Create Class based on this" in CB doesn't allow me to name the class

[CL 2517970 by Richard TalbotWatkin in Main branch]
This commit is contained in:
Richard TalbotWatkin
2015-04-20 14:22:39 -04:00
committed by epic@richtech.es
parent 0f3091b982
commit ee38b591f9
2 changed files with 12 additions and 32 deletions
@@ -11,6 +11,7 @@
#include "ISourceControlModule.h"
#include "MessageLog.h"
#include "Engine/BlueprintGeneratedClass.h"
#include "ContentBrowserModule.h"
#define LOCTEXT_NAMESPACE "AssetTypeActions"
@@ -175,26 +176,13 @@ void FAssetTypeActions_Blueprint::ExecuteNewDerivedBlueprint(TWeakObjectPtr<UBlu
FString Name;
FString PackageName;
CreateUniqueAssetName(Object->GetOutermost()->GetName(), TEXT("_Child"), PackageName, Name);
const FString PackagePath = FPackageName::GetLongPackagePath(PackageName);
UPackage* Package = CreatePackage(NULL, *PackageName);
if (ensure(Package))
{
// Create and init a new Blueprint
UBlueprint* NewBP = FKismetEditorUtilities::CreateBlueprint(TargetParentClass, Package, FName(*Name), BPTYPE_Normal, TargetParentBP->GetClass(), UBlueprintGeneratedClass::StaticClass());
if (NewBP)
{
// Notify the asset registry
FAssetRegistryModule::AssetCreated(NewBP);
UBlueprintFactory* BlueprintFactory = NewObject<UBlueprintFactory>();
BlueprintFactory->ParentClass = TargetParentClass;
// the editor should be opened AFTER being added to the asset
// registry (some systems could queue off of the asset registry
// add event, and already having that blueprint open can be odd)
FAssetEditorManager::Get().OpenEditorForAsset(NewBP);
// Mark the package dirty...
Package->MarkPackageDirty();
}
}
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
ContentBrowserModule.Get().CreateNewAsset(Name, PackagePath, UBlueprint::StaticClass(), BlueprintFactory);
}
}