I’ve successfully loaded Blueprint assets dynamically by using FSoftObjectPath to ResolveObject() and TryLoad(), but ONLY IN EDITOR.
When I try to run the same code in a package build or dedicated server, I get the “LogUObjectGlobals:Warning: Failed to find object…” error, which I believe typically occurs when you haven’t cooked your required assets properly. The thing is, however, I have cooked everything and even tried using “Cook everything in the project content directory”… to no avail.
The code is as follows:
FSoftObjectPath ItemToReference(AssetString);
UObject* ItemObject = ItemToReference.ResolveObject(); // <---- FAILS
if (!ItemObject) // if the asset isn't in memory already, try to load it
{
ItemObject = ItemToReference.TryLoad(); // <---- FAILS
}
if (ItemObject)
{
UBlueprintCore* GeneratedBP = Cast<UBlueprintCore>(ItemObject);
// .... continue to spawn object using GeneratedBP...
}
(I also read somewhere that UBlueprint doesn’t work in Packaged builds, so my code uses UBlueprintCore instead)
Is this not the right method for loading assets dynamically in a packaged game? I have read about the FStreamableManager, but that appears to be a much more involving solution than necessary for what I’m trying to do.
Again, the code works perfectly in editor, so I assume this has to do with the running a packaged build.