✓ Accepted answer
The PreloadAsync function loads multiple decals at once rather then the old Preload which in tern only loaded the decals 1 by 1
I've re-written the code from the PreloadAsync page from the page you specified, Hopefully its a little clearer on how to use the new Async preload function.
Note:
the table below in the code isn't required to use PreloadAsync function its just a way to set a flag (true/false) when the decal has loaded or not
you can use a simple table like:
local ContentProvider = game:GetService("ContentProvider")
local Decals = {
"rbxassetid://1234561",
"rbxassetid://1234562"
}
local function getStatus(contentId, status)
if(status == Enum.AssetFetchStatus.Success) then
print(contentId.." Loaded!")
end
end
ContentProvider:PreloadAsync(Decals , getStatus)
Might be a better format:
local ContentProvider = game:GetService("ContentProvider")
local Decals = {
{
DecalID = "rbxassetid://1234561",
Loaded = false
},
{
DecalID = "rbxassetid://1234565",
Loaded = false
}
}
local DecTble = {}
for k,v in pairs(Decals) do
DecTble[k] = v.DecalID
end
local function getStatus(contentId, status,Table)
if(status == Enum.AssetFetchStatus.Success) then
Table.Loaded = true
end
end
for k,v in pairs(Decals) do
ContentProvider:PreloadAsync(DecTble, function(contentId, status) getStatus(contentId, status,v) end)
end
for k,v in pairs(Decals) do
print("[",k,"] Decal = [",v.DecalID,"] Loaded = [",v.Loaded,"]")
end
Hope this helps! :)
1 comment
Alr, thank you for the answer.