iniside
(iniside)
June 22, 2014, 11:31am
1
I got my self to this point:
FStringAssetReference itemRef = "Class'/Game/Blueprints/Items/Chest/chestBlue.chestBlue_C'";
UObject* itemObj = itemRef.ResolveObject();
AARArmor* item = GetWorld()->SpawnActor<AARArmor>(itemObj->GetClass(), SpawnInfo);
And the first two lines work.
When inspecting in debugger itemObj, UClass is pointing the the right blueprint.
But SpawnActor is returning null. What I’m doing wrong ?
iniside
(iniside)
June 22, 2014, 11:49am
2
I figured it out:
FStringAssetReference itemRef = "Blueprint'/Game/Blueprints/Items/Chest/chestBlue.chestBlue'";
UObject* itemObj = itemRef.ResolveObject();
UBlueprint* gen = Cast<UBlueprint>(itemObj);
AARArmor* item = GetWorld()->SpawnActor<AARArmor>(gen->GeneratedClass, SpawnInfo);
All that is needed, is to create UBlueprint (figures…) and then just get GeneratedClass. You can shorten it by directly casting to UBlueprint.
I found that the ResolveObject always returns NULL because the blueprint is not yet loaded.
So I added the following before the Resolve…
TArray LoadedObjects;
if (EngineUtils::FindOrLoadAssetsByPath( selAssets[i].PackagePath.ToString(), LoadedObjects, EngineUtils::ATL_Class))
{
// Do the resolve here...
}