學習
引擎類別
CapturesPages
無法建立
未複製

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要
繼承成員
範例程式碼
從畫廊讀取捕捉並遍歷頁面
local CaptureService = game:GetService("CaptureService")
local function readCapturesFromGallery()
local allCaptures = {}
local capturesPages
local success, result = pcall(function()
local readResult, pages = CaptureService:ReadCapturesFromGalleryAsync({}, false)
if readResult == Enum.ReadCapturesFromGalleryResult.Success then
capturesPages = pages
end
return readResult
end)
if not success or result ~= Enum.ReadCapturesFromGalleryResult.Success then
-- 可能是權限錯誤,請參見 CaptureService:PromptCaptureGalleryPermissionAsync()
warn("獲取初始捕捉失敗: " .. result.Name)
return
end
-- 遍歷當前頁面
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- 進入下一頁直到完成
while not capturesPages.IsFinished do
local advanceToNextPageSuccess, _ = pcall(function()
capturesPages:AdvanceToNextPageAsync()
end)
if not advanceToNextPageSuccess then
return
end
currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
end
return allCaptures
end
©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。