FSoftObjectPath's ResolveObject() and TryLoad() do not work for PACKAGED build?

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.

BTW, if it matters, the AssetString above is in the format Blueprint’/Game/Actor1.Actor1’

The above link was very helpful. I’m now using “Class’/… /…/name**_C” for the asset names instead (i.e. need to do some work on the reference copied from the UE4 engine first) and they are spawning in package and editor both. Sweet.

Hey Orakga,

In my previous post (that you reference in your answer), the class was loaded in the constructor, which wasn’t satisfying for a complete dynamic loading.

I opened a BR for the exact same problem (thinking the problem was elsewhere in an asset manager function) and found out it wasn’t a bug, just UE4 making things more difficult than they should.

I finally figured out it was again the same problem showing up one more time, and so i posted a complete working solution here once and for all:

https://answers.unrealengine.com/questions/729231/requestasyncload-cant-find-assets-in-packaged-game.html

Hopefully it’ll help many people bumping into the same problem :slight_smile:

Cheers

Cedric

Thank you Cedric. I checked out your example as well, and apparently it works with “Blueprint…” as well? Anyhow, thanks again for sharing your findings!