요약
메서드
GetAssetFetchStatus(contentId: ContentId):Enum.AssetFetchStatus |
GetAssetFetchStatusChangedSignal(contentId: ContentId):RBXScriptSignal |
Preload(contentId: ContentId):() |
PreloadAsync(contentIdList: {any},callbackFunction: function):() |
RegisterDefaultEncryptionKey(encryptionKey: string):() |
RegisterDefaultSessionKey(sessionKey: string):() |
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 참조
속성
RequestQueueSize
코드 샘플
콘텐츠 제공자 로딩 바
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
매개 변수
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
매개 변수
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)Preload
PreloadAsync
반환
()
코드 샘플
자산 미리 로드
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:", assetFetchStatus)
end
-- 콘텐츠를 미리 로드하고 시간을 측정합니다
local startTime = os.clock()
ContentProvider:PreloadAsync(assets, callback)
local deltaTime = os.clock() - startTime
print(("미리 로드 완료, 소요 시간 %.2f 초"):format(deltaTime))RegisterDefaultEncryptionKey
RegisterDefaultSessionKey
RegisterEncryptedAsset
RegisterSessionEncryptedAsset
UnregisterDefaultEncryptionKey
ContentProvider:UnregisterDefaultEncryptionKey():()
반환
()
UnregisterEncryptedAsset
ContentProvider:UnregisterEncryptedAsset(assetId:ContentId):()
매개 변수
assetId:ContentId |
반환
()
이벤트
AssetFetchFailed