ContentProvider:PreloadAsync and Preload update

To enhance asset type safety, ContentProvider:PreloadAsync function now works with instance list. It will gather asset ids from instances and their children recursively.

An example : ContentProvider:PreloadAsync({ game.Workspace.Model1, game.Workspace.Part1})

If you pass in id strings (the old way), those ids will be assumed as images, other types will failed to request. This will cause some error messages printed out. Edit: Sorry for the trouble I caused today. I’ve turned this off. Now you can take your time to make an update.

Edit: I’ll enable it Aug 31th. And we will deprecate ContentProvider:Preload function in the near future. The only recomendation for preload will be ContentProvider:PreloadAsync with instances.

58 Likes

This is awesome, thanks!

1 Like

Uh oh, so audio preloading with asset urls will fail - Not severely game-breaking, though games that used it that way may want to update their code now. :thinking:

1 Like

Considering my game is loaded with audio files around the game and images. This is great, I don’t have to make a giant list of Ids.

Will we need to preload audios as in-game assets rather than IDs now?

1 Like

yes

1 Like

Wait what’s the difference between IDs and in-game assets? I don’t think i’ve used an ‘in-game asset’, I’ve always used the the URL-like string for defining ImageLabel.Image, sound.SoundId, decal.Texture, is that what an ID is?

1 Like

So now we can preload unions? That’s awesome.

3 Likes

Is this live?

Really bugs me how sound IDs don’t preload now. Each of my weapons has a module with the weapon sound IDs and now I can’t peload them :\

5 Likes

And this is meaning we can preload unions now? Description is kind of vague… Cuz that’s awesome, preloading is essential…

An id is a URL-lilke string. A instance means a game object that have an asset id as a property. This function will check different types of object and get asset id from them.

You can create some Audio objects in script with your original ids and pass them to the function.

ah ok to preload sounds

local SoundObject = Workspace.SoundObject
SoundObject.SoundId = "URL-like string"

ContentProvider:PreloadAsync({SoundObject})

That’s how it’s done now I think

3 Likes

Isn’t that kinda counter productive tho? I don’t want to create excessive audio instances until I need them

15 Likes

Out of curiosity, how was this being abused? Were users preloading places or something?

Please tell me this is a warning and not saying it is about to go live. I need to redo a lot of my loading screen in Ultimate Boxing or I will get a lot of complaints of long loading times.

2 Likes

Its already live, got errors in my game so I had to turn of preloading by soundId

3 Likes

It’s not really related to this function. We added type check to asset requests. So by getting asset ids from instances, client will know what type of asset it is.

2 Likes

Fix it! Easy fix, so no need to fret :P

function preloadSoundsById(soundIdList)
    local soundInstances = {}

    for _,soundId in next,soundIdList do
        local soundInstance = Instance.new("Sound")
        soundInstance.SoundId = "rbxassetid://"..soundId
        table.insert(soundInstances, soundInstance)
    end

    game:GetService("AssetService"):PreloadAsync(soundInstances)
end
5 Likes