Engine Class
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