(UPDATED): say I’m using a function with a map variable and calling a custom event(in the fnc) feeding the variable to the custom event as a parameter(pass by ref), and In the custom event I would go through each item in an (eg: player inventory) and first check the map if it contains the temporary loaded data asset, if not I would load async and store the asset in that temporary map so the next loop can make use of it if there are items of the same type or should I just avoid this and go through loading the items using async load asset?, will UE for eg: if one item of the same type is loaded will the other use that loaded data asset in the loop?, if so In this case I don’t need to do the map thing
If I understand your idea right, it’s basically loading the items in the background so you can that the items loading doesn’t interrupt the rest of the game. I think the only problem is that it’ll take up memory space, by having all Item Data Assets loaded all the time. But if they’re small enough or few enough, and depending on your project’s requirements, this may not be an issue. Up to you!
One thing I would try instead, is using it as a sort of on-demand loading. When an item is needed, check the map. If it’s not there, you do that item’s first Async Load Asset and store it in the map (as opposed to storing in the map before the item is even requested). The only issue with that is that depending on how long it takes to load one item, it might be noticeable, but on the flip side, you never load items that aren’t necessary.
storing the assets will keep them permanently alive which makes you responsible for memory management, which can be fine.
Async load is instant if its already loaded anyway or you can even try resolve the soft ref first and if its invalid load then.
DataAssets also support asset bundles which can load groups of assets.
i cant really give you a concrete answer it depends on your game, most indie games can probably get away with all assets in memory, but then maybe you dont need soft refs at all.
I don’t mean to keep all data assets loaded all the time, also this:
When an item is needed, check the map. If it’s not there, you do that item’s first Async Load Asset and store it in the map
is kinda what I suggested, yep I’m kinda bad at explaining stuff xd, I wanna know whether if its efficient or unnecessary/redundant what I’m suggesting, lemme explain it in more detail:
I’m gonna use a function with a map variable and calling a custom event(in the fnc) feeding the variable to the custom event as a parameter(pass by ref), and In the custom event I would go through each item in an (eg: player inventory) and first check the map if it contains the temporary loaded data asset, if not I would load async and store the asset in that temporary map so the next loop can make use of it if there are items of the same type or should I just avoid this and go through loading the items using async load asset?, will UE for eg: if one item of the same type is loaded will the other use that loaded data asset in the loop?, if so In this case I don’t need to do the map thing
i might still be misunderstanding but you cant load something twice, its either loaded or unloaded so no need to save it in a map, if you do save it though it wont be unloaded since it will block garbage collection.
so if that’s kinda what you mean no need for the map.
it might be better to explain your use case though, if you plan to async load a group of assets in an inventory then it could cause problems with the user trying to access unloaded assets.
in that case its likely better to preload all assets or try to ‘predict’ when an asset may be needed which is complicated.