How do I "Front Load" Object files that are currently being loaded asynchronously

tl;dr: special effect assets are loading asynchronously. This is bad. How do I load these files at the same time the Level loads?

I wrote better details below. Thanks in advance to anyone that can help!

Background:

I’m creating a Plugin that reorganizes special effects into a special UClass I wrote. This makes them more designer-friendly, (there’s more features I want to keep quiet, though).

Problem:

But these assets are loading asynchronously (i.e. at runtime), and that is bad when they’re fired by an AnimNotifyState. The effect might load after NotifyEnd(…) runs, so I need to figure this out.

Solution:

So, I want these all loaded during the startup process, when the level loads.

Implementation:

I have no idea how to do this. My current guess is, I override PostLoad() in the GameModeBase class. I wrote code to find all AActors that own a copy of the Plugin’s Component, and copy the TSoftObjectPtrs each sound and particle effect that can be fired. And then I was hoping to make a call from the UAssetManager, but I think those are all Asynchronous, too.

I do not know the first thing about loading assets during the level load, and the documentation for asset management is incredibly complicated. Can anyone help me solve this problem?

You can create an actor that you place below the level and have it execute the FX on load, therefore having them loaded in while the level loads.

1 Like

i’d use the asset registry to find them and async load them in the GameMode BeginPlay behind a load screen.

1 Like

I’m reading up on the Asset Registry. The documentation says it’s a Subsystem associated with the Editor. It will probably work when I test the game in PIE, but do you know if it works in standalone builds?

So here is what I did, and this worked pretty well…

I took your suggestion, and in my Subsystem’s OnWorldBeginPlay(UWorld& InWorld) function I grabbed the AssetManager and the StreamableManager. I used those to build Object Libraries and from them Synchronously load the files from FAssetData. Something like…

UObjectLibrary* AssetTypeObjectLibrary = UObjectLibrary::CreateLibrary(UAssetClass::StaticClass(), true, GIsEditor);
AssetTypeObjectLibrary->AddToRoot();
int32 AssetCount = _PresentationFXObjectLibrary->LoadBlueprintAssetDataFromPath(TEXT(“/Game/Path/Where/All/Assets/Found”));
TArray Data;
AssetTypeObjectLibrary->GetAssetDataList(_PEGData);
for (const FAssetData& AData : Data)
{
StreamableManager.LoadSynchronous(FSoftObjectPath or TSoftObjectPtr)
}

Thank you so much for your help!

2 Likes