I tried to get that working in my standalone cpp class, but I could not figure out how to set asset.PackageName and asset.AssetName correctly. After a great deal of google “coding” I now have a solution:
FString bpResource = "/Game/Blueprints/BP_Wall_A.BP_Wall_A";
UBlueprint* GeneratedBP = Cast<UBlueprint>(StaticLoadObject(UObject::StaticClass(), NULL, *bpResource));
UWorld* World = GetWorld();
World->SpawnActor<AActor>(GeneratedBP->GeneratedClass, FVector(0, 0, 0), FRotator(0, 0, 0));
For anyone else finding this post and needing clarification:
“/Game” is the position of your “Content” folder and the name of the blueprint is the name as it appears in your blueprint (or whatever you called it) folder, with a . and then the name again.
I need to think a bit about what is actually happening in the StaticLoadObject line.
Perhaps it is a UE5 thing, but I found I did not need to specify the SpawnParams.