学ぶ
エンジンクラス
ContentProvider
作成できません
サービス
複製されていません

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。


概要
方法
Preload(contentId: ContentId):()
非推奨
PreloadAsync(contentIdList: {any},callbackFunction: function):()
RegisterEncryptedAsset(assetId: ContentId,encryptionKey: string):()
RegisterSessionEncryptedAsset(contentId: ContentId,sessionKey: string):()
UnregisterEncryptedAsset(assetId: ContentId):()
イベント
AssetFetchFailed(assetId: ContentId):RBXScriptSignal
継承されたメンバー
コードサンプル
コンテンツプロバイダー
local ContentProvider = game:GetService("ContentProvider")
local LOGO_ID = "rbxassetid://658743164"
local PAGE_TURN_ID = "rbxassetid://12222076"
local decal = Instance.new("Decal")
decal.ColorMapContent = Content.fromUri(LOGO_ID)
local sound = Instance.new("Sound")
sound.SoundId = PAGE_TURN_ID
local assets = { decal, sound }
ContentProvider:PreloadAsync(assets)
print("すべてのアセットが読み込まれました。")

APIリファレンス
プロパティ
BaseUrl
読み取り専用
複製されていません
並列読み取り
機能: AssetManagement
ContentProvider.BaseUrl:string

RequestQueueSize
読み取り専用
複製されていません
並列読み取り
機能: AssetManagement
ContentProvider.RequestQueueSize:number
コードサンプル
コンテンツプロバイダーのロードバー
local ContentProvider = game:GetService("ContentProvider")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local playerGui = localPlayer:WaitForChild("PlayerGui")
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = playerGui
-- 基本的なロードバーを作成
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.5, 0, 0.1, 0)
frame.Position = UDim2.new(0.5, 0, 0.5, 0)
frame.AnchorPoint = Vector2.new(0.5, 0.5)
frame.Parent = screenGui
local bar = Instance.new("Frame")
bar.Size = UDim2.new(0, 0, 1, 0)
bar.Position = UDim2.new(0, 0, 0, 0)
bar.BackgroundColor3 = Color3.new(0, 0, 1)
bar.Parent = frame
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
local sound2 = Instance.new("Sound")
sound2.SoundId = "rbxassetid://9120385974"
local assets = {
sound,
sound2,
}
task.wait(3)
for i = 1, #assets do
local asset = assets[i]
ContentProvider:PreloadAsync({ asset }) -- 1つずつ、待機します
local progress = i / #assets
bar.Size = UDim2.new(progress, 0, 1, 0)
end
print("ローディング完了")

方法
GetAssetFetchStatus
機能: AssetManagement
ContentProvider:GetAssetFetchStatus(contentId:ContentId):Enum.AssetFetchStatus
パラメータ
contentId:ContentId
コードサンプル
アセットの取得状況の監視
local ContentProvider = game:GetService("ContentProvider")
-- ロードするアセットの例
local ASSET_ID = "rbxassetid://9120386436"
local exampleAsset = Instance.new("Sound")
exampleAsset.SoundId = ASSET_ID
-- アセットの現在の AssetFetchStatus を出力します
local initialAssetFetchStatus = ContentProvider:GetAssetFetchStatus(ASSET_ID)
print("初期 AssetFetchStatus:", initialAssetFetchStatus)
-- 更新をリッスンします
local assetFetchStatusChangedSignal = ContentProvider:GetAssetFetchStatusChangedSignal(ASSET_ID)
local function onAssetFetchStatusChanged(newAssetFetchStatus: Enum.AssetFetchStatus)
print(`新しい AssetFetchStatus: {newAssetFetchStatus}`)
end
assetFetchStatusChangedSignal:Connect(onAssetFetchStatusChanged)
-- アセットのプリロードをトリガーします
local function onAssetRequestComplete(contentId: string, assetFetchStatus: Enum.AssetFetchStatus)
print(`プリロード状況 {contentId}: {assetFetchStatus.Name}`)
end
ContentProvider:PreloadAsync({ exampleAsset }, onAssetRequestComplete)

GetAssetFetchStatusChangedSignal
機能: AssetManagement
ContentProvider:GetAssetFetchStatusChangedSignal(contentId:ContentId):RBXScriptSignal
パラメータ
contentId:ContentId
コードサンプル
アセットの取得状況の監視
local ContentProvider = game:GetService("ContentProvider")
-- ロードするアセットの例
local ASSET_ID = "rbxassetid://9120386436"
local exampleAsset = Instance.new("Sound")
exampleAsset.SoundId = ASSET_ID
-- アセットの現在の AssetFetchStatus を出力します
local initialAssetFetchStatus = ContentProvider:GetAssetFetchStatus(ASSET_ID)
print("初期 AssetFetchStatus:", initialAssetFetchStatus)
-- 更新をリッスンします
local assetFetchStatusChangedSignal = ContentProvider:GetAssetFetchStatusChangedSignal(ASSET_ID)
local function onAssetFetchStatusChanged(newAssetFetchStatus: Enum.AssetFetchStatus)
print(`新しい AssetFetchStatus: {newAssetFetchStatus}`)
end
assetFetchStatusChangedSignal:Connect(onAssetFetchStatusChanged)
-- アセットのプリロードをトリガーします
local function onAssetRequestComplete(contentId: string, assetFetchStatus: Enum.AssetFetchStatus)
print(`プリロード状況 {contentId}: {assetFetchStatus.Name}`)
end
ContentProvider:PreloadAsync({ exampleAsset }, onAssetRequestComplete)

ListEncryptedAssets
機能: AssetManagement
ContentProvider:ListEncryptedAssets():{any}
戻り値

Preload
非推奨

PreloadAsync
イールド
機能: AssetManagement
ContentProvider:PreloadAsync(
contentIdList:{any}, callbackFunction:function
):()
パラメータ
contentIdList:{any}
callbackFunction:function
既定値: "nil"
戻り値
()
コードサンプル
アセットのプリロード
local ContentProvider = game:GetService("ContentProvider")
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
local decal = Instance.new("Decal")
decal.ColorMapContent = Content.fromUri("rbxassetid://5447528495")
local assets = {
decal,
sound,
}
-- 各アセットが解決されるときにヒットします
local callback = function(assetId, assetFetchStatus)
print("PreloadAsync() が解決したアセットID:", assetId)
print("PreloadAsync() 最終アセット取得ステータス:", assetFetchStatus)
end
-- コンテンツをプリロードし、その時間を計測します
local startTime = os.clock()
ContentProvider:PreloadAsync(assets, callback)
local deltaTime = os.clock() - startTime
print(("プリロード完了、所要時間 %.2f 秒"):format(deltaTime))

RegisterDefaultEncryptionKey
機能: AssetManagement
ContentProvider:RegisterDefaultEncryptionKey(encryptionKey:string):()
パラメータ
encryptionKey:string
戻り値
()

RegisterDefaultSessionKey
機能: AssetManagement
ContentProvider:RegisterDefaultSessionKey(sessionKey:string):()
パラメータ
sessionKey:string
戻り値
()

RegisterEncryptedAsset
機能: AssetManagement
ContentProvider:RegisterEncryptedAsset(
assetId:ContentId, encryptionKey:string
):()
パラメータ
assetId:ContentId
encryptionKey:string
戻り値
()

RegisterSessionEncryptedAsset
機能: AssetManagement
ContentProvider:RegisterSessionEncryptedAsset(
contentId:ContentId, sessionKey:string
):()
パラメータ
contentId:ContentId
sessionKey:string
戻り値
()

UnregisterDefaultEncryptionKey
機能: AssetManagement
ContentProvider:UnregisterDefaultEncryptionKey():()
戻り値
()

UnregisterEncryptedAsset
機能: AssetManagement
ContentProvider:UnregisterEncryptedAsset(assetId:ContentId):()
パラメータ
assetId:ContentId
戻り値
()

イベント
AssetFetchFailed
機能: AssetManagement
ContentProvider.AssetFetchFailed(assetId:ContentId):RBXScriptSignal
パラメータ
assetId:ContentId

©2026 Roblox Corporation。Roblox(ロブロックス)、RobloxロゴおよびPowering Imaginationは、米国並びにその他の国における登録商標および非登録商標です。