Classe motore
CaptureService
*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.
Sommario
Metodi
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 |
Eventi
CaptureBegan(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureEnded(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureSaved(captureInfo: Dictionary):RBXScriptSignal |
UserCaptureSaved(captureContentId: ContentId):RBXScriptSignal |
Riferimento API
Metodi
CaptureScreenshot
CheckUploadCaptureStatusAsync
PromptCaptureGalleryPermissionAsync
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
Parametri
Restituzioni
Campioni di codice
Richiesta di autorizzazione per la galleria di acquisizioni
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
-- Richiesta di autorizzazione per la galleria di acquisizioni
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
endPromptSaveCapturesToGallery
ReadCapturesFromGalleryAsync
Restituzioni
Campioni di codice
Leggi le catture dalla galleria e itera sulle pagine
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
-- Probabilmente un errore di autorizzazione, vedere CaptureService:PromptCaptureGalleryPermissionAsync()
warn("Impossibile ottenere le catture iniziali: " .. result.Name)
return
end
-- Itera attraverso la pagina corrente
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- Avanza alla pagina successiva fino al termine
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(
Parametri
| Valore predefinito: "nil" |
Restituzioni
StopVideoCapture
CaptureService:StopVideoCapture():()
Restituzioni
()
TakeScreenshotCaptureAsync
Parametri
| Valore predefinito: "nil" |
Restituzioni
()
UploadCaptureAsync
Parametri
Restituzioni
Campioni di codice
Carica la cattura nel sistema di asset
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
-- Gestisci il fallimento
return nil
end
return assetId
end)
if not success then
-- Gestisci l'errore
return nil
end
return result
endEventi
CaptureBegan
Parametri
CaptureEnded
Parametri
CaptureSaved
UserCaptureSaved
Parametri
captureContentId:ContentId |