It’s perhaps not too difficult to achieve, but right now I don’t find the right information concerning this.
I want to create a new blueprint in C++ as part of an importer module within our project, which I’m writing myself. With that I mean creating an actual full blueprint asset file (not just a node or a function etc.), that goes into the editor’s asset browser for content creators to use. I want to be able to define the name, superclass and file path of the blueprint in my function.
FString PackageName = TEXT("/Game/SomePackageLocation/" + name);
UPackage *Package = CreatePackage(NULL, *PackageName);
UMyAsset *NewAsset = new (Package, FName("MyAsset"), Flags | RF_Public)
UMyAsset(FPostConstructInitializeProperties());
if (NewAsset != NULL)
{
// Fill in the assets data here
}
FAssetRegistryModule::AssetCreated(NewAsset);
NewAsset->MarkPackageDirty();
I’m don’t know how to use this code snipped or what exactly it does (I can only assume it creates an asset) and I also think it’s not applicable to what I want to achieve, since I want a blueprint based on a given superclass.
That already goes in the right direction. The difference is, that my goal doesn’t involve using the editor at the point of blueprint creation. It’s all about automation as part of a character import tool chain. The import (JSON data) is invoked in the editor, that’s true. After that, data is read, converted and should then automatically create blueprints for each imported character, so each blueprint should simply be based on our character class.
That looks like the function I would need. Does this already create a new asset and then I’d only need to call FAssetRegistryModule::AssetCreated(NewAsset);
to have it registered? Unfortunately I can’t try right now, so I ask just to be sure up front.
For my case this works, it creates the asset, saves it, and opens up the blueprint window in editor upon creation, which is all I need. However, as a warning, I ran in to trouble when I tried to save the asset before opening up the blueprint window in editor.