ContentProvider:PreloadAsync and Preload update

News about preload

Out of curiosity, how will I be able to know how many assets are in the queue to preload? Iā€™d like to scale my loading screen based on how many assets I pass into PreloadAsync (I do have plans to go insane by preloading the entire workspace). Should I still use RequestQueueSize?

Essentially what I want to accomplish is this:

  • Game states itā€™s loading sounds
  • Passes all sounds into PreloadAsync
  • When all sounds are preloaded, move on to another asset type
  • Repeat until everything I want is done
1 Like

Now there is no way to get this data. You can still use RequestQueueSize, but it only means the num of assets waiting for download. My suggestion is to break the whole assets into groups and call this function several times. So you can tell the progress.

1 Like

say I did it like that but for decals just so I can have the image pre-loaded, wouldnā€™t I need to Destroy every new Decal Object I make or would it be automatically removed after sometime?

Pretty sure theyā€™d be automatically garbage collected if you modify that to set the table variable to nil because there is no parent and all references to the objects are lost. Even if left as-is, the performance impact of just storing simple objects in memory is negligible, even if you have 100s.

One problem: I canā€™t preload accessories.

You should be able to. Insert them with InsertService, and then preload the SpecialMesh(es) inside the inserted accessory.

Thatā€™s what I did-
image

I preloaded it, but PreloadAsync got stuck.

I cannot reproduce. Do you have the output open? It might be giving an error or warning thatā€™s causing the script to break and not execute anything past it. If I insert the Soldier model by UristMcSparks from the Toolbox, select the gun mesh, and then run the following code, it preloads just fine:

game:GetService("ContentProvider"):PreloadAsync({game.Selection:Get()[1]}) print("Test")

Is it only that specific mesh thatā€™s broken? If so, can you attach it as a rbxm file here?

I fixed it. Nothing more.