Can't load blueprints in built project

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

+MapsToCook=(FilePath="/Game/Maps/StartMap")
+DirectoriesToAlwaysCook=(Path="/Game/Gameplay/Enemies")
+DirectoriesToAlwaysCook=(Path="/Game/Gameplay/Pickups/Consumables")
+DirectoriesToAlwaysCook=(Path="/Game/Gameplay/Pickups/Other")
+DirectoriesToAlwaysCook=(Path="/Game/Gameplay/Pickups/Passives")

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:


ItemLibrary->LoadAssetDataFromPath(TEXT("/Game/Gameplay/Pickups"));

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;
		else
		{
			FString GeneratedClassName = ItemAssets[i].AssetName.ToString() + "_C";
			ClassToAdd = FindObject<UClass>(ItemAssets[i].GetPackage(), *GeneratedClassName);
		}