I am trying to extend the editor and create a Blueprint with a custom actor parent class.
The menu extension button launches this code:
FString NameStr = "/Game/Blueprint";
UPackage* myPackage = CreatePackage(NULL, *NameStr);
AMyClass* myClass = NewObject<AMyClass>();
UBlueprintFactory* myFactory = NewObject<UBlueprintFactory>();
UBlueprint* myBP = Cast<UBlueprint>(myFactory->FactoryCreateNew(UBlueprint::StaticClass(), myPackage, FName("MyInfo"), RF_Public | RF_Standalone, NULL, GWarn));
if (myBP)
{
myBP->ParentClass = myClass->StaticClass();
//Notify the asset registry
FAssetRegistryModule::AssetCreated(myBP);
//Mark the package dirty...
myBP->MarkPackageDirty();
}
If I just use AActor as the parent class it works fine, so I guess the problem lies with my custom actor class.
MyClass.h:
UCLASS(Blueprintable, NonTransient)
class AMyClass : public AActor
{
GENERATED_BODY()
public:
AMyClass(const FObjectInitializer& ObjectInitializer);
};
MyClass.cpp:
AMyClass::AMyClass(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
Everything compiles fine, but when I click the menu button I get the following error:
Cast of Package /Engine/Transient to Level failed
Any ideas as to why this is happening or how to fix?
Thanks in advance!
-Tim