Creating UBlueprint Factory

Hello,

I’m trying to create a UActorFactory to create child blueprints of my native C++ class. Then call methods on that new blueprint asset.

I’ve managed to create a UBlueprint object that the parent class is of my C++ class, but I’m struggling with how to cast this UBlueprint to my Class.

This is how I’m creating the Blueprint:

UObject* UBasicItemActorFactory::FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
{	
	UBlueprint* NewBPObject = FKismetEditorUtilities::CreateBlueprint(UExampleClass::StaticClass(), InParent, InName, BPTYPE_Normal, UBlueprint::StaticClass(), UBlueprintGeneratedClass::StaticClass(), NAME_None);
	...
}

I’m doing this to enable my Factory to call functions and/or set properties on this new asset.

Is what I’m trying to do possible?

Thanks,
-Jon

Hi there.
You can take a look at my implementation here: ActorInteractionPlugin/InteractableComponentAssetFactory.cpp at main · Mountea-Framework/ActorInteractionPlugin (github.com)

The factory must be registered for the class in Module file: ActorInteractionPlugin/ActorInteractionPluginEditor.cpp at main · Mountea-Framework/ActorInteractionPlugin (github.com)

I hope it helps.

1 Like