Can't load blueprints in built project

I’ve been trying to get this working for over a month now, and I just can’t figure it out.
I have a couple of folders of blueprints I need to load at runtime.

I’ve tried LoadAssetDataFromPath, EngineUtils::FindOrLoadAssetsByPath and LoadBlueprintsFromPath, all of them find my assets when running from the editor, but none of them find my assets once I package my project.
I have added the folders to the list of additional folders to cook and I’m using their GeneratedBlueprints, but still no go.
What am I missing?

	EngineUtils::FindOrLoadAssetsByPath(TEXT("/Game/Gameplay/Enemies"), EnemyList, EngineUtils::ATL_Regular);
	//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Magenta, FString::FromInt(EnemyList.Num()));

It finds 0 items in the built project.

I found a suggestion to use: FPaths::ConvertRelativePathToFull(path);
But that made no difference either.

I think you still need to reference the asset somewhere, if you’re adding additional folders to cook, but the cooker finds no dependencies on them, it’ll still ignore them. I do believe there is a list of things you can force it to cook, though I may actually be completely wrong on this. But I’m pretty sure I’m right . . .

That sounds like it’s the case!
I’m finding people having this issue all the way back to UE4 launching.
It appears that adding folders to cook is supposed to cook unreferenced uassets in those folders, but it was never properly implemented and still has to be manually forced.
I havent yet found a way to do it myself, but found someone having success packaging and building through “UAT”, but I’m not familiar with that and not sure if that’s still applicable?

(To be fair, I’m actually using UE5, but I’ve found 99% of documentation and support for ue4 to be fully compatible so far, it’s more like a big update than a new engine)

Was it “DirectoriesToAlwaysCook” that you added it to?


… like that?

looks like that’s what’s used in my project, and seems to work

i’m pretty sure there’s also a different ini setting for directories to scan but pretty sure AlwaysCook gets included into the package

Yeah, I did, they do show up in my defaultgame.ini:


MapsToCook worked, but none of gameplay folders are picked up.

I guess I could potentially create an object that’s hardcoded to point to all the classes to force a reference, but that feels more like taping over a crack in the wall than fixing it.

Edit: I tried manually placing some of these blueprints in the level to confirm whether or not it’s a reference issue, but it still doesn’t find anything, so good shout, but looks like it’s due to something else.

Edit: Turns out I am actually finding the blueprints if I use:


However, it’s crashing due to not being able to get the generated class for some reason.

	//Get class to use for spawning

		iBP = ItemAssets[i].GetPackage()->GetFName().ToString();

		UObject* ItemActor = StaticLoadObject(UObject::StaticClass(), NULL, *iBP);

		UBlueprint* GeneratedBP = Cast<UBlueprint>(ItemActor);
		ClassToAdd = GeneratedBP->GeneratedClass;

If I add a breakpoint, I find that ItemActor is a nullptr.

Edit3: I finally fixed it!

I ended up using LoadBlueprintAssetDataFromPath, which finds 2 different versions of the assets, I then seperate them out and get it working in the packaged build like this:

UBlueprint* GeneratedBP = Cast<UBlueprint>(ItemAssets[i].GetAsset());
		if (GeneratedBP)
			ClassToAdd = GeneratedBP->GeneratedClass;
			FString GeneratedClassName = ItemAssets[i].AssetName.ToString() + "_C";
			ClassToAdd = FindObject<UClass>(ItemAssets[i].GetPackage(), *GeneratedClassName);

Welp, it worked in 4.26 and 5EA, but I’ve now updated to 5.01 and it no longer works and cannot find my blueprints once more. Any suggestions on what has changed and what I need to change to fix it?

your solution almost worked for me in 5.1, just had to remove the + “_C”, so it would be like this:

UBlueprint* GeneratedBP = Cast<UBlueprint>(ItemAssets[i].GetAsset());
		if (GeneratedBP)
			ClassToAdd = GeneratedBP->GeneratedClass;
			FString GeneratedClassName = ItemAssets[i].AssetName.ToString();
			ClassToAdd = FindObject<UClass>(ItemAssets[i].GetPackage(), *GeneratedClassName);

after removing the “+ _C” it worked perfectly

Yeah, I discovered that too, that I had to basically turn it back around again for some reason.