学习
引擎类
CaptureService
无法创建
服务

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处


概要
方法
CaptureScreenshot(onCaptureReady: function):()
PromptSaveCapturesToGallery(captures: {any},resultCallback: function):()
PromptShareCapture(captureContent: Content,launchData: string,onAcceptedCallback: function,onDeniedCallback: function):()
ReadCapturesFromGalleryAsync(captureTypeFilters: {any},readFromAllEligibleExperiences: boolean):Tuple
TakeScreenshotCaptureAsync(onCaptureReady: function,captureParams: Dictionary):()
继承成员

API 参考
方法
CaptureScreenshot
功能: Capture
CaptureService:CaptureScreenshot(onCaptureReady:function):()
参数
onCaptureReady:function
返回
()

CheckUploadCaptureStatusAsync
暂停
功能: Capture
CaptureService:CheckUploadCaptureStatusAsync(token:string):Tuple
参数
token:string
返回

PromptCaptureGalleryPermissionAsync
暂停
功能: Capture
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
参数
captureGalleryPermission:Enum.CaptureGalleryPermission
返回
代码示例
提示用户获取捕获画廊权限
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
-- 请求捕获画廊权限
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
end

PromptSaveCapturesToGallery
功能: Capture
CaptureService:PromptSaveCapturesToGallery(
captures:{any}, resultCallback:function
):()
参数
captures:{any}
resultCallback:function
返回
()

PromptShareCapture
功能: Capture
CaptureService:PromptShareCapture(
captureContent:Content, launchData:string, onAcceptedCallback:function, onDeniedCallback:function
):()
参数
captureContent:Content
launchData:string
onAcceptedCallback:function
onDeniedCallback:function
返回
()

ReadCapturesFromGalleryAsync
暂停
功能: Capture
CaptureService:ReadCapturesFromGalleryAsync(
captureTypeFilters:{any}, readFromAllEligibleExperiences:boolean
参数
captureTypeFilters:{any}
默认值:"{}"
readFromAllEligibleExperiences:boolean
默认值:false
返回
代码示例
从画廊读取捕获并遍历页面
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

StartUploadCaptureAsync
暂停
功能: Capture
CaptureService:StartUploadCaptureAsync(capture:Capture):Tuple
参数
capture:Capture
返回

StartVideoCaptureAsync
暂停
功能: Capture
CaptureService:StartVideoCaptureAsync(
onCaptureReady:function, captureParams:Dictionary
参数
onCaptureReady:function
captureParams:Dictionary
默认值:"nil"

StopVideoCapture
功能: Capture
CaptureService:StopVideoCapture():()
返回
()

TakeScreenshotCaptureAsync
功能: Capture
CaptureService:TakeScreenshotCaptureAsync(
onCaptureReady:function, captureParams:Dictionary
):()
参数
onCaptureReady:function
captureParams:Dictionary
默认值:"nil"
返回
()

UploadCaptureAsync
暂停
功能: Capture
CaptureService:UploadCaptureAsync(capture:Capture):Tuple
参数
capture:Capture
返回
代码示例
上传捕捉到资产系统
local CaptureService = game:GetService("CaptureService")
local function uploadCapture(capture: Capture)
local success, result = pcall(function()
local uploadCaptureResult, assetId = CaptureService:UploadCaptureAsync(capture)
if uploadCaptureResult ~= Enum.UploadCaptureResult.Success then
-- 处理失败
return nil
end
return assetId
end)
if not success then
-- 处理错误
return nil
end
return result
end

活动
CaptureBegan
功能: Capture
CaptureService.CaptureBegan(captureType:Enum.CaptureType):RBXScriptSignal
参数
captureType:Enum.CaptureType

CaptureEnded
功能: Capture
CaptureService.CaptureEnded(captureType:Enum.CaptureType):RBXScriptSignal
参数
captureType:Enum.CaptureType

CaptureSaved
已弃用

UserCaptureSaved
功能: Capture
CaptureService.UserCaptureSaved(captureContentId:ContentId):RBXScriptSignal
参数
captureContentId:ContentId

©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。