I'm trying to use Async Load Asset inside a For Each loop. It doesn't work. How to load an array of objects that are soft referenced?

It appears to me that there is only one “Async Load Asset” instance. If it loads something but doesn’t finish loading, and you tell it to load something else, it will stop loading the previous object and try to load the new one.

I have a custom For Each Loop where I can specify a delay and using this method works. Because I’m waiting half a second to give the next command and Async Load Asset manages to finish the previous task. Obviously this can’t work in the real world because you don’t know how fast the player computer is and how much time it takes to load a resource.

It appears I’m missing something here. There is a need to load multiple assets at runtime, right? So how can I load them?

1 Like

See this

1 Like

this is interesting and may work for me, I will see if I can implement it properly. Thank You.

Checking a bunch of info on this stuff, it appears that if you use this async Load function in code in C++, it lets you define a function that you can use to take care of the loaded object. A delegate or something, whatever that is

I didn’t try the above because I’m need to first learn how to use C++ in unreal and how all this works. I don’t have a week to learn all this code stuff just to see if it works.

So maybe the function loads the object but it doesn’t give it back properly in a loop in blueprint. You practically don’t know where it is in memory

A second solution may be that pesky Asset manager, which appears to let you define some rules to load a bunch of assets at the time, but oh my god is incredible the lack of clear tutorials for people like me on this topic.

tried this setup loop node but the editor tells me that it detected an infinite loop. doesn’t let me use it

You need to make sure you exit the loop at some point. This is why in the example I provided, I fill an array before starting the loop, then in each execution I grab the first element and remove it from the array.

If you wanna switch to c++, look into FStreamableManagerRequestAsyncLoad, which is much more convenient as it can effectively load batches. You simply give it an array of SoftObjectPtr/SoftObjectPath.

I will try to understand how the Asset manager works. I think I need to define some rules then I can use it to automatically load the assets. Its a bit arcane how it works for now. The official documentation is written like you already know what they are talking about which doesn’t help