I am trying to dynamicly load blueprints:
First I load assets in UObjectLibrary like that:

        UObjectLibrary * lib = UObjectLibrary::CreateLibrary(base_class, true, GIsEditor);
        int32 loaded = lib->LoadBlueprintAssetDataFromPath(path);
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Cyan, FString::FromInt(loaded) + TEXT(" objects loaded for lib - ") + name);

Then i`am trying to find asset by name, then load in by FAssetData::GetAsset, and return TSubclassOf<Ship> to spawn in blueprints;

	for (int32 i = 0; i < Assets.Num(); ++i) {
		FAssetData& assetData = Assets*;
		if (assetData.AssetName.ToString() == name) {
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("AssetFound - ") + assetData.AssetName.ToString());
			if (!assetData.GetAsset())
				GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Get ship: Failed to load object by GetAsset - ") + assetData.AssetName.ToString());

			UBlueprint * bp = Cast<UBlueprint>(assetData.GetAsset());
			if (bp) {
				GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("Get ship: bleprint cast done for asset - ") + assetData.AssetName.ToString());
				if (bp->GeneratedClass->IsChildOf(AShip::StaticClass())) {
					return *(bp->GeneratedClass);
				} else {
					GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Get ship: Class isn`t cild of AShip- ") + assetData.AssetName.ToString());
			} else {
				GEngine-&gt;AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Get ship: bleprint cast FAILED for asset - ") + assetData.AssetName.ToString());

In editor this code works perfectly, as well as in Standalone>. But when i bush Launch, and Unreal builds really “standalone” game for me, assedData.GetAsset returns NULL. I can`t undestand why it fails to load object.

I find out that StaticLoadObject(called by GetAsset) fails to load my blueprint with the message:
LogUObjectGlobals:Warning: Failed to find object ‘Object /Game/blueprints/ships/FirstShip.FirstShip’
I also, find out that StaticFindObjectFast returns NULL for me when i Launch the game and works fine when i bush “Play” Button.

May be it`s a BUG?

I may be way off base, but I’m guessing some of these systems only exist with the editor build - look for “WITH_EDITOR_ONLY” in the headers.

I sorted out the problem.
UObjectLibrary::LoadBlueprintAssetDataFromPath(path) - loads info about blueprint assets by path. In editor mode i can get them, and then get GeneratedClass of them. When game is cooked there is “no blueprints” there is only GeneratedClass. So i can load GeneratedClass directly by adding “_C” to object path.

Hey MadScorp, are you saying that you removed UObjectLibrary::LoadBlueprintAssetDataFromPath(path)? Did you use UObjectLibrary::LoadAssetDataFromPath instead?

1 Like

Done code example here - https://answers.unrealengine.com/questions/89482/dynamic-blueprints-loading.html#answer-309155