요약
메서드
CaptureScreenshot(onCaptureReady: function):() |
CheckUploadCaptureStatusAsync(token: string):Tuple |
PromptCaptureGalleryPermissionAsync(captureGalleryPermission: Enum.CaptureGalleryPermission):boolean |
PromptSaveCapturesToGallery(captures: {any},resultCallback: function):() |
PromptShareCapture(captureContent: Content,launchData: string,onAcceptedCallback: function,onDeniedCallback: function):() |
ReadCapturesFromGalleryAsync(captureTypeFilters: {any},readFromAllEligibleExperiences: boolean):Tuple |
StartUploadCaptureAsync(capture: Capture):Tuple |
StartVideoCaptureAsync(onCaptureReady: function,captureParams: Dictionary):Enum.VideoCaptureStartedResult |
StopVideoCapture():() |
TakeScreenshotCaptureAsync(onCaptureReady: function,captureParams: Dictionary):() |
UploadCaptureAsync(capture: Capture):Tuple |
이벤트
CaptureBegan(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureEnded(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureSaved(captureInfo: Dictionary):RBXScriptSignal |
UserCaptureSaved(captureContentId: ContentId):RBXScriptSignal |
상속된 멤버
API 참조
메서드
CaptureScreenshot
매개 변수
반환
()
코드 샘플
스크린샷 캡처
local CaptureService = game:GetService("CaptureService")
-- 이 코드를 포함하는 스크립트의 ImageLabel 부모에 대한 참조
local imageLabel = script.Parent
local function onCaptureReady(contentId)
imageLabel.Image = contentId
end
CaptureService:CaptureScreenshot(onCaptureReady)CheckUploadCaptureStatusAsync
PromptCaptureGalleryPermissionAsync
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
매개 변수
반환
코드 샘플
캡처 갤러리 권한 요청
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
endPromptSaveCapturesToGallery
반환
()
코드 샘플
프롬프트 공유 캡처
local CaptureService = game:GetService("CaptureService")
local function onShareAccepted()
print("공유 캡처가 수락되었습니다!")
end
local function onShareDenied()
print("공유 캡처가 거부되었습니다!")
end
local onCaptureReady = function(result, videoCapture)
if videoCapture then
local captureContent = Content.fromObject(videoCapture)
CaptureService:PromptShareCapture(captureContent, "launchData" , onShareAccepted, onShareDenied)
end
end
CaptureService:StartVideoCaptureAsync(onCaptureReady, {})ReadCapturesFromGalleryAsync
반환
코드 샘플
갤러리에서 캡처를 읽고 페이지를 반복합니다
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
endStartUploadCaptureAsync
StartVideoCaptureAsync
CaptureService:StartVideoCaptureAsync(
매개 변수
| 기본값: "nil" |
코드 샘플
비디오 캡처 비동기 시작
local CaptureService = game:GetService("CaptureService")
local tool = Instance.new("Tool")
tool.Parent = workspace
local onCaptureReady = function(result, videoCapture)
if result ~= Enum.VideoCaptureResult.Success and result ~= Enum.VideoCaptureResult.TimeLimitReached or not videoCapture then
print("비디오 녹화가 다음 이유로 완료되지 않았습니다:", result)
else
-- 사용자에게 비디오 캡처를 갤러리에 저장하라는 메시지를 표시합니다.
CaptureService:PromptSaveCapturesToGallery({ videoCapture }, function()
print("캡처가 저장되었습니다")
end)
end
end
tool.Activated:Connect(function()
local videoRecordingAllowedResult: Enum.VideoCaptureStartedResult = CaptureService:StartVideoCaptureAsync(onCaptureReady, {})
if videoRecordingAllowedResult ~= Enum.VideoCaptureStartedResult.Success then
print("비디오 녹화가 다음 이유로 시작되지 않았습니다:", videoRecordingAllowedResult)
end
end)StopVideoCapture
CaptureService:StopVideoCapture():()
반환
()
TakeScreenshotCaptureAsync
매개 변수
| 기본값: "nil" |
반환
()
코드 샘플
스크린샷 캡처 비동기
local CaptureService = game:GetService("CaptureService")
local parent = Instance.new("Tool")
parent.Parent = workspace
local onCaptureReady = function(result, screenshotCapture)
if result ~= Enum.ScreenshotCaptureResult.Success or not screenshotCapture then
print("스크린샷이 다음 이유로 완료되지 않았습니다:", result)
else
-- 사용자에게 스크린샷 캡처를 갤러리에 저장하라는 메시지를 표시합니다.
CaptureService:PromptSaveCapturesToGallery({ screenshotCapture }, function(results)
for capture, result in pairs(results) do
if result then
print("캡처가 저장되었습니다")
end
end
end)
end
end
parent.Activated:Connect(function()
CaptureService:TakeScreenshotCaptureAsync(onCaptureReady, { UICaptureMode = Enum.UICaptureMode.All })
end)UploadCaptureAsync
매개 변수
반환
코드 샘플
자산 시스템에 캡처 업로드
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
매개 변수
CaptureEnded
매개 변수
CaptureSaved
UserCaptureSaved
매개 변수
captureContentId:ContentId |