Skip to main content
Use este tema para comprender cómo usar los contenedores de API para llamar correctamente a las API de Microsoft Game Development Kit (GDK) y de los servicios de XBOX desde código administrado.

Acceso a las API de Microsoft Game Development Kit (GDK)

Después de importar el paquete de API de Microsoft GDK desde Unity, su funcionalidad está disponible en el espacio de nombres XGamingRuntime. Todas las API de Gaming Runtime están disponibles mediante métodos estáticos en la clase SDK. Todas las API de los servicios de XBOX están disponibles mediante métodos estáticos en la clase SDK.XBL. En el ejemplo siguiente se muestra esta disponibilidad.

Cobertura y convenciones de las API

No todas las API están disponibles a través del paquete. Para obtener una lista completa de estas API, consulte las listas de API de Microsoft Game Development Kit (GDK) y de los servicios de XBOX más adelante en este tema.
Convenciones:
  • Los nombres de las API coinciden con sus equivalentes del GDK siempre que es posible.
  • Sin excepciones. Los errores se comunican mediante HRESULT.
  • Superficie de API plana sin encapsulación orientada a objetos.
  • Se usan parámetros out en las API que establecen parámetros.
  • Los métodos asincrónicos usan devoluciones de llamada. Para obtener más información, consulte la sección siguiente.

Modelo de programación asincrónica

La mayoría de las API asincrónicas aceptan una devolución de llamada como último parámetro. A continuación se muestra un ejemplo.
La información sobre el modelo de subprocesos es la siguiente.
  • Los métodos asincrónicos se ejecutan inmediatamente y el trabajo se realiza en un subproceso disponible del grupo de subprocesos.
    • El grupo de subprocesos se inicializa internamente después de realizar una llamada a SDK.XGameRuntimeInitialize().
    • No se exponen opciones de configuración del grupo de subprocesos.
  • La devolución de llamada de resultado se invoca después de que se llame a dispatch (es decir, SDK.XTaskQueueDispatch()). Como consecuencia, es importante que dispatch se llame con frecuencia, idealmente durante el bucle de actualización del juego.
  • La devolución de llamada de resultado se ejecuta en el subproceso que invocó dispatch.

Ejemplos de diferencias entre las API nativas y los contenedores administrados

Las API nativas y los contenedores administrados tienen diferencias mínimas. Como referencia, los dos ejemplos siguientes muestran las funciones de firma y llamada de XUserAddAsync y XblAchievementsUpdateAchievementAsync en código administrado y nativo.

Ejemplo de XUserAddAsync

La firma nativa de XUserAddAsync es la siguiente.
Mientras que la firma administrada de XUserAddAsync es:
A continuación se muestra un ejemplo de cómo llamar a las funciones de XUserAddAsync en código nativo.
Mientras que el ejemplo administrado de llamada a las funciones de XUserAddAsync es:
Si prefiere usar una cola personalizada, o si la API no incluye una implementación de devolución de llamada, el ejemplo siguiente muestra cómo crear un XAsyncBlock. También debe garantizar el envío y la finalización correctos de la cola. Para obtener más información, consulte Información general de la biblioteca XTaskQueue.

Ejemplo de XblAchievementsUpdateAchievementAsync

La firma nativa de XblAchievementsUpdateAchievementAsync es la siguiente.
Mientras que la firma administrada de XblAchievementsUpdateAchievementAsync es:
A continuación se muestra un ejemplo de cómo llamar a las funciones de XblAchievementsUpdateAchievementAsync en código nativo.
Mientras que el ejemplo administrado de llamada a las funciones de XblAchievementsUpdateAchievementAsync es:

Inicialización de XBOX Services API (XSAPI) en código administrado

Como referencia, la siguiente es una inicialización de XSAPI en código administrado. Esta es la firma de XSAPI en código administrado.
El siguiente es un ejemplo del patrón de llamada de XSAPI en código administrado.

Lista de API de Microsoft Game Development Kit (GDK) en contenedores administrados

Las siguientes API de Microsoft Game Development Kit (GDK) se incluyen en contenedores administrados dentro del paquete del GDK para Unity. Para obtener más información sobre las API de Microsoft Game Development Kit (GDK), consulte Referencia de API del sistema.
  • XAccessibility
    • XClosedCaptionGetProperties
    • XClosedCaptionSetEnabled
    • XHighContrastGetMode
    • XSpeechToTextSendString
    • XSpeechToTextSetPositionHint
    • XSpeechToTextBeginHypothesisString
    • XSpeechToTextUpdateHypothesisString
    • XSpeechToTextFinalizeHypothesisString
    • XSpeechToTextCancelHypothesisString
  • XAppCapture
    • XAppBroadcastGetStatus
    • XAppBroadcastIsAppBroadcasting
    • XAppBroadcastShowUI
    • XAppBroadcastRegisterIsAppBroadcastingChanged
    • XAppCaptureCloseLocalStream
    • XAppCaptureCloseScreenshotStream
    • XAppCaptureEnableRecord
    • XAppCaptureDisableRecord
    • XAppBroadcastUnregisterIsAppBroadcastingChanged
    • XAppCaptureMetadataAddStringEvent
    • XAppCaptureMetadataAddInt32Event
    • XAppCaptureMetadataAddDoubleEvent
    • XAppCaptureMetadataStartStringState
    • XAppCaptureMetadataStartInt32State
    • XAppCaptureMetadataStartDoubleState
    • XAppCaptureMetadataStopState
    • XAppCaptureMetadataStopAllStates
    • XAppCaptureMetadataRemainingStorageBytesAvailable
    • XAppCaptureOpenScreenshotStream
    • XAppCaptureReadScreenshotStream
    • XAppCaptureRecordDiagnosticClip
    • XAppCaptureTakeDiagnosticScreenshot
    • XAppCaptureTakeScreenshot
    • XAppCaptureRegisterMetadataPurged
    • XAppCaptureUnRegisterMetadataPurged
    • XAppCaptureReadLocalStream
    • XAppCaptureRecordTimespan
    • XAppCaptureGetVideoCaptureSettings
  • XAsync
    • XAsyncGetStatus
    • XAsyncGetResultSize
    • XAsyncCancel
    • XAsyncRun
  • XDisplay
    • XDisplayTryEnableHdrMode
    • XDisplayAcquireTimeoutDeferral
    • XDisplayCloseTimeoutDeferralHandle
  • XError
    • XErrorSetCallback
    • XErrorSetOptions
  • XGameEvent
    • XGameEventWrite
  • XGame
    • XGameGetXboxTitleId
    • XLaunchNewGame
    • XLaunchRestartOnCrash
  • XGameInvite
    • XGameInviteRegisterForEvent
    • XGameInviteUnregisterForEvent
  • XGameProtocol
    • XGameProtocolRegisterForActivation
    • XGameProtocolUnregisterForActivation
  • XGameRuntimeFeature
    • XGameRuntimeIsFeatureAvailable
  • XGameRuntimeInit
    • XGameRuntimeInitialize
    • XGameRuntimeUninitialize
  • XGameSave
    • XGameSaveInitializeProvider
    • XGameSaveInitializeProviderAsync
    • XGameSaveInitializeProviderResult
    • XGameSaveCloseProvider
    • XGameSaveGetRemainingQuota
    • XGameSaveGetRemainingQuotaAsync
    • XGameSaveGetRemainingQuotaResult
    • XGameSaveDeleteContainer
    • XGameSaveDeleteContainerAsync
    • XGameSaveDeleteContainerResult
    • XGameSaveCreateContainer
    • XGameSaveCloseContainer
    • XGameSaveGetContainerInfo
    • XGameSaveEnumerateContainerInfo
    • XGameSaveEnumerateContainerInfoByName
    • XGameSaveEnumerateBlobInfo
    • XGameSaveEnumerateBlobInfoByName
    • XGameSaveReadBlobData
    • XGameSaveReadBlobDataAsync
    • XGameSaveReadBlobDataResult
    • XGameSaveCreateUpdate
    • XGameSaveCloseUpdateHandle
    • XGameSaveSubmitBlobWrite
    • XGameSaveSubmitBlobDelete
    • XGameSaveSubmitUpdate
    • XGameSaveSubmitUpdateAsync
    • XGameSaveSubmitUpdateResult
  • XGameSaveFiles
    • XGameSaveFilesGetFolderWithUiAsync
    • XGameSaveFilesGetFolderWithUiResult
    • XGameSaveFilesGetRemainingQuota
  • XGameStreaming
    • XGameStreamingInitialize
    • XGameStreamingUninitialize
    • XGameStreamingIsStreaming
    • XGameStreamingGetClientCount
    • XGameStreamingGetClients
    • XGameStreamingGetConnectionState
    • XGameStreamingRegisterConnectionStateChanged
    • XGameStreamingUnregisterConnectionStateChanged
    • XGameStreamingHideTouchControls
    • XGameStreamingHideTouchControlsOnClient
    • XGameStreamingShowTouchControlLayout
    • XGameStreamingShowTouchControlLayoutOnClient
    • XGameStreamingRegisterClientPropertiesChanged
    • XGameStreamingUnregisterClientPropertiesChanged
    • XGameStreamingGetStreamPhysicalDimensions
    • XGameStreamingGetStreamAddedLatency
    • XGameStreamingGetServerLocationNameSize
    • XGameStreamingGetServerLocationName
    • XGameStreamingIsTouchInputEnabled
    • XGameStreamingGetLastFrameDisplayed
    • XGameStreamingUpdateTouchControlsState
    • XGameStreamingUpdateTouchControlsStateOnClient
    • XGameStreamingShowTouchControlsWithStateUpdate
    • XGameStreamingShowTouchControlsWithStateUpdateOnClient
    • XGameStreamingGetTouchBundleVersionNameSize
    • XGameStreamingGetTouchBundleVersion
    • XGameStreamingGetClientIPAddress
    • XGameStreamingGetSessionId
    • XGameStreamingGetDisplayDetails
    • XGameStreamingSetResolution
  • XGameUI
    • XGameUIShowAchievementsAsync
    • XGameUIShowAchievementsResult
    • XGameUIShowMessageDialogAsync
    • XGameUIShowMessageDialogResult
    • XGameUIShowErrorDialogAsync
    • XGameUIShowErrorDialogResult
    • XGameUIShowTextEntryAsync
    • XGameUIShowTextEntryResultSize
    • XGameUIShowTextEntryResult
    • XGameUITextEntryClose
    • XGameUITextEntryGetExtents
    • XGameUITextEntryOpen
    • XGameUITextEntryGetState
    • XGameUITextEntryUpdatePositionHint
    • XGameUITextEntryUpdateVisibility
    • XGameUISetNotificationPositionHint
    • XGameUIShowSendGameInviteAsync
    • XGameUIShowSendGameInviteResult
    • XGameUIShowMultiplayerActivityGameInviteAsync
    • XGameUIShowMultiplayerActivityGameInviteResult
    • XGameUIShowWebAuthenticationAsync
    • XGameUIShowWebAuthenticationResult
    • XGameUIShowWebAuthenticationWithOptionsAsync
    • XGameUIShowWebAuthenticationResultSize
    • XGameUIShowPlayerProfileCardAsync
    • XGameUIShowPlayerProfileCardResult
    • XGameUIShowPlayerPickerAsync
    • XGameUIShowPlayerPickerResultCount
    • XGameUIShowPlayerPickerResult
  • XLauncher
    • XLaunchUri
  • XNetworking
    • XNetworkingGetConnectivityHint
    • XNetworkingQueryConfigurationSetting
    • XNetworkingQueryPreferredLocalUdpMultiplayerPort
    • XNetworkingQueryPreferredLocalUdpMultiplayerPortAsync
    • XNetworkingQueryPreferredLocalUdpMultiplayerPortAsyncResult
    • XNetworkingQuerySecurityInformationForUrlAsync
    • XNetworkingQuerySecurityInformationForUrlAsyncResultSize
    • XNetworkingQuerySecurityInformationForUrlAsyncResult
    • XNetworkingQuerySecurityInformationForUrlUtf16Async
    • XNetworkingQuerySecurityInformationForUrlUtf16AsyncResultSize
    • XNetworkingQuerySecurityInformationForUrlUtf16AsyncResult
    • XNetworkingQueryStatistics
    • XNetworkingRegisterConnectivityHintChanged
    • XNetworkingUnregisterConnectivityHintChanged
    • XNetworkingRegisterPreferredLocalUdpMultiplayerPortChanged
    • XNetworkingUnregisterPreferredLocalUdpMultiplayerPortChanged
    • XNetworkingVerifyServerCertificate
  • XPackage
    • XPackageGetCurrentProcessPackageIdentifier
    • XPackageIsPackagedProcess
    • XPackageGetUserLocale
    • XPackageEnumeratePackages
    • XPackageFindChunkAvailability
    • XPackageChangeChunkInstallOrder
    • XPackageInstallChunks
    • XPackageUninstallChunks
    • XPackageInstallChunksAsync
    • XPackageInstallChunksResult
    • XPackageRegisterPackageInstalled
    • XPackageUnregisterPackageInstalled
    • XPackageEnumerateFeatures
    • XPackageEnumerateChunkAvailability
    • XPackageMount
    • XPackageMountWithUiAsync
    • XPackageMountWithUiResult
    • XPackageGetMountPath
    • XPackageGetMountPathSize
    • XPackageCloseMountHandle
    • XPackageCreateInstallationMonitor
    • XPackageCloseInstallationMonitorHandle
    • XPackageGetInstallationProgress
    • XPackageUpdateInstallationMonitor
    • XPackageRegisterInstallationProgressChanged
    • XPackageUnregisterInstallationProgressChanged
    • XPackageEstimateDownloadSize
    • XPackageGetWriteStats
    • XPackageUninstallUWPInstance
    • XPackageUninstallPackage
  • XPersistentLocalStorage
    • XPersistentLocalStorageGetPathSize
    • XPersistentLocalStorageGetPath
    • XPersistentLocalStorageGetSpaceInfo
    • XPersistentLocalStoragePromptUserForSpaceAsync
    • XPersistentLocalStoragePromptUserForSpaceResult
  • XSpeechSynthesizer
    • XSpeechSynthesizerEnumerateInstalledVoices
    • XSpeechSynthesizerCreate
    • XSpeechSynthesizerCloseHandle
    • XSpeechSynthesizerSetDefaultVoice
    • XSpeechSynthesizerSetCustomVoice
    • XSpeechSynthesizerCreateStreamFromText
    • XSpeechSynthesizerCreateStreamFromSsml
    • XSpeechSynthesizerCloseStreamHandle
    • XSpeechSynthesizerGetStreamDataSize
    • XSpeechSynthesizerGetStreamData
  • XStore
    • XStoreCreateContext
    • XStoreCloseContextHandle
    • XStoreIsAvailabilityPurchasable
    • XStoreAcquireLicenseForPackageAsync
    • XStoreAcquireLicenseForPackageResult
    • XStoreCanAcquireLicenseForPackageAsync
    • XStoreCanAcquireLicenseForPackageResult
    • XStoreCanAcquireLicenseForStoreIdAsync
    • XStoreCanAcquireLicenseForStoreIdResult
    • XStoreCloseLicenseHandle
    • XStoreIsLicenseValid
    • XStoreQueryAddOnLicensesAsync
    • XStoreQueryAddOnLicensesResultCount
    • XStoreQueryAddOnLicensesResult
    • XStoreQueryGameLicenseAsync
    • XStoreQueryGameLicenseResult
    • XStoreQueryLicenseTokenAsync
    • XStoreQueryLicenseTokenResultSize
    • XStoreQueryLicenseTokenResult
    • XStoreRegisterGameLicenseChanged
    • XStoreUnregisterGameLicenseChanged
    • XStoreRegisterPackageLicenseLost
    • XStoreUnregisterGameLicenseChanged
    • XStoreUnregisterPackageLicenseLost
    • XStoreAcquireLicenseForDurablesAsync
    • XStoreQueryGameAndDlcPackageUpdatesAsync
    • XStoreQueryGameAndDlcPackageUpdatesResultCount
    • XStoreQueryGameAndDlcPackageUpdatesResult
    • XStoreDownloadAndInstallPackagesAsync
    • XStoreDownloadAndInstallPackagesResultCount
    • XStoreDownloadAndInstallPackagesResult
    • XStoreDownloadAndInstallPackageUpdatesAsync
    • XStoreDownloadAndInstallPackageUpdatesResult
    • XStoreDownloadPackageUpdatesAsync
    • XStoreDownloadPackageUpdatesResult
    • XStoreQueryPackageIdentifier
    • XStoreShowRedeemTokenUIAsync
    • XStoreShowRedeemTokenUIResult
    • XStoreShowRateAndReviewUIAsync
    • XStoreShowRateAndReviewUIResult
    • XStoreShowPurchaseUIAsync
    • XStoreShowPurchaseUIResult
    • XStoreQueryConsumableBalanceRemainingAsync
    • XStoreQueryConsumableBalanceRemainingResult
    • XStoreReportConsumableFulfillmentAsync
    • XStoreReportConsumableFulfillmentResult
    • XStoreGetUserCollectionsIdAsync
    • XStoreGetUserCollectionsIdResultSize
    • XStoreGetUserCollectionsIdResult
    • XStoreGetUserPurchaseIdAsync
    • XStoreGetUserPurchaseIdResultSize
    • XStoreGetUserPurchaseIdResult
    • XStoreQueryAssociatedProductsAsync
    • XStoreQueryAssociatedProductsResult
    • XStoreQueryEntitledProductsAsync
    • XStoreQueryEntitledProductsResult
    • XStoreQueryProductForCurrentGameAsync
    • XStoreQueryProductForCurrentGameResult
    • XStoreQueryProductForPackageAsync
    • XStoreQueryProductForPackageResult
    • XStoreQueryProductsAsync
    • XStoreQueryProductsResult
    • XStoreProductsQueryNextPageAsync
    • XStoreCloseProductsQueryHandle
    • XStoreAcquireLicenseForDurablesResult
    • XStoreEnumerateProductsQuery
    • XStoreProductsQueryHasMorePages
    • XStoreProductsQueryNextPageResult
    • XStoreShowAssociatedProductsUIAsync
    • XStoreShowAssociatedProductsUIResult
    • XStoreShowProductPageUIAsync
    • XStoreShowProductPageUIResult
  • XSystem
    • XSystemGetAnalyticsInfo
    • XSystemGetAppSpecificDeviceId
    • XSystemGetConsoleId
    • XSystemGetDeviceType
    • XSystemGetXboxLiveSandboxId
    • XSystemGetRuntimeInfo
    • XSystemIsHandleValid
    • XSystemHandleTrack
  • XTaskQueue
    • XTaskQueueCloseHandle
    • XTaskQueueCreate
    • XTaskQueueCreateComposite
    • XTaskQueueDispatch
    • XTaskQueueDuplicateHandle
    • XTaskQueueGetCurrentProcessTaskQueue
    • XTaskQueueGetPort
    • XTaskQueueRegisterMonitor
    • XTaskQueueRegisterWaiter
    • XTaskQueueSetCurrentProcessTaskQueue
    • XTaskQueueSubmitCallback
    • XTaskQueueSubmitDelayedCallback
    • XTaskQueueTerminate
    • XTaskQueueUnregisterMonitor
    • XTaskQueueUnregisterWaiter
  • XThread
    • XThreadIsTimeSensitive
    • XThreadSetTimeSensitive
    • XThreadAssertNotTimeSensitive
  • XUser
    • XUserDuplicateHandle
    • XUserCloseHandle
    • XUserCompare
    • XUserGetMaxUsers
    • XUserAddAsync
    • XUserAddResult
    • XUserAddByIdWithUiAsync
    • XUserAddByIdWithUiResult
    • XUserGetId
    • XUserFindUserById
    • XUserGetLocalId
    • XUserFindUserByLocalId
    • XUserGetIsGuest
    • XUserGetState
    • XUserGetGamertag
    • XUserGetGamerPictureAsync
    • XUserGetAgeGroup
    • XUserCheckPrivilege
    • XUserResolvePrivilegeWithUiAsync
    • XUserResolvePrivilegeWithUiResult
    • XUserGetTokenAndSignatureUtf16Async
    • XUserResolveIssueWithUiUtf16Async
    • XUserResolveIssueWithUiUtf16Result
    • XUserRegisterForChangeEvent
    • XUserUnregisterForChangeEvent
    • XUserCloseSignOutDeferralHandle
    • XUserFindControllerForUserWithUiAsync
    • XUserFindControllerForUserWithUiResult
    • XUserFindForDevice
    • XUserGetDefaultAudioEndpointUtf16
    • XUserGetGamerPictureResultSize
    • XUserGetGamerPictureResult
    • XUserGetSignOutDeferral
    • XUserGetTokenAndSignatureAsync
    • XUserGetTokenAndSignatureResultSize
    • XUserGetTokenAndSignatureResult
    • XUserGetTokenAndSignatureUtf16ResultSize
    • XUserGetTokenAndSignatureUtf16Result
    • XUserIsStoreUser
    • XUserRegisterForDefaultAudioEndpointUtf16Changed
    • XUserRegisterForDeviceAssociationChanged
    • XUserResolveIssueWithUiAsync
    • XUserResolveIssueWithUiResult
    • XUserUnregisterForDefaultAudioEndpointUtf16Changed
    • XUserUnregisterForDeviceAssociationChanged

Lista de API de los servicios de XBOX en contenedores administrados

Las siguientes API de los servicios de XBOX se incluyen en contenedores administrados dentro del paquete del GDK para Unity. Para obtener más información sobre las API de los servicios de XBOX, consulte Referencia de API de XBOX Live.

Documentación de referencia de las API

Consulte también

Introducción a Unity para el desarrollo en PC
Última modificación el 28 de agosto de 2026