概要
robloxでassistantやってみた。
練習問題、やってみた。
練習問題
ContentProviderを使え。
サンプルコード
local ContentProvider = game:GetService("ContentProvider")
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
local decal = Instance.new("Decal")
decal.Texture = "rbxassetid://5447528495"
local assets = {
decal,
sound,
}
local callback = function(assetId, assetFetchStatus)
print("PreloadAsync() resolved asset ID:", assetId)
print("PreloadAsync() final AssetFetchStatus:", assetFetchStatus)
end
local startTime = os.clock()
ContentProvider:PreloadAsync(assets, callback)
local deltaTime = os.clock() - startTime
print(("Preloading complete, took %.2f seconds"):format(deltaTime))
実行結果
11:29:03.693 Hello world! - サーバー
11:29:05.331 PreloadAsync() resolved asset ID: rbxassetid://9120386436 - クライアント - LocalScript:13
11:29:05.331 PreloadAsync() final AssetFetchStatus: Enum.AssetFetchStatus.Success - クライアント - LocalScript:14
11:29:05.937 Hello world! - クライアント
11:29:06.819 PreloadAsync() resolved asset ID: rbxassetid://5447528495 - クライアント - LocalScript:13
11:29:06.819 PreloadAsync() final AssetFetchStatus: Enum.AssetFetchStatus.Success - クライアント - LocalScript:14
11:29:07.322 Preloading complete, took 2.46 seconds - クライアント - LocalScript:19
以上。