PreloadAsync

作者: jaycex2020 | 来源:发表于2022-02-17 11:18 被阅读0次

    This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.

    https://developer.roblox.com/en-us/api-reference/function/ContentProvider/PreloadAsync

    local ContentProvider = game:GetService("ContentProvider")

    -- Create some objects to be preloaded

    local sound = Instance.new("Sound")

    sound.SoundId = "rbxassetid://1838058421"

    local decal = Instance.new("Decal")

    decal.Texture = "rbxassetid://5447528495"

    -- A table of various assets to preload (Instances or content)

    local assets = {

    decal,

    sound,

    "rbxassetid://5173222739",

    "rbxthumb://type=Avatar&w=100&h=100&id=269323"

    }

    -- For demonstration, pre-load 50 random user's avatar thumbnails

    for i = 1, 50 do

    table.insert(assets, "rbxthumb://type=Avatar&w=100&h=100&id=" .. math.random(1,1000000))

    end

    -- Preload the content and time it

    local startTime = os.clock()

    ContentProvider:PreloadAsync(assets)

    local deltaTime = os.clock() - startTime

    print(("Preloading complete, took %.2f seconds"):format(deltaTime))

    相关文章

      网友评论

        本文标题:PreloadAsync

        本文链接:https://www.haomeiwen.com/subject/bqpdlrtx.html