Skip to main content
Utilisez cette rubrique pour comprendre comment utiliser les wrappers d’API afin d’appeler correctement les API du Microsoft Game Development Kit (GDK) et des XBOX services à partir de code managé.

Accès aux API du Microsoft Game Development Kit (GDK)

Une fois que vous avez importé le package d’API du Microsoft GDK depuis Unity, ses fonctionnalités sont disponibles sous l’espace de noms XGamingRuntime. Toutes les API Gaming Runtime sont disponibles via des méthodes statiques de la classe SDK. Toutes les API des XBOX services sont disponibles via des méthodes statiques de la classe SDK.XBL. L’exemple suivant illustre cette disponibilité.

Couverture des API et conventions

Toutes les API ne sont pas disponibles via le package. Pour obtenir la liste complète de ces API, consultez les listes d’API du Microsoft Game Development Kit (GDK) et des XBOX services plus loin dans cette rubrique.
Conventions :
  • Les noms des API correspondent à leurs équivalents du GDK dans la mesure du possible.
  • Aucune exception. Les erreurs sont communiquées via des HRESULT.
  • Surface d’API plate, sans encapsulation orientée objet.
  • Des paramètres out sont utilisés dans les API qui définissent des paramètres.
  • Les méthodes asynchrones utilisent des rappels. Pour plus de détails, consultez la section suivante.

Modèle de programmation asynchrone

La plupart des API asynchrones prennent un rappel comme dernier paramètre. En voici un exemple.
Voici des informations sur le modèle de threading.
  • Les méthodes asynchrones s’exécutent immédiatement, et le travail est effectué sur un thread disponible du pool de threads.
    • Le pool de threads est initialisé en interne après un appel à SDK.XGameRuntimeInitialize().
    • Aucune option de configuration du pool de threads n’est exposée.
  • Le rappel de résultat est invoqué après l’appel de la distribution (c’est-à-dire SDK.XTaskQueueDispatch()). Il est donc important que la distribution soit appelée fréquemment, idéalement pendant la boucle de mise à jour de votre jeu.
  • Le rappel de résultat est exécuté sur le thread qui a invoqué la distribution.

Exemples de différences entre les API natives et les wrappers managés

Les API natives et les wrappers managés présentent des différences minimes. À titre de référence, les deux exemples suivants montrent la signature et les fonctions d’appel de XUserAddAsync et XblAchievementsUpdateAchievementAsync en code managé et natif.

Exemple XUserAddAsync

La signature native de XUserAddAsync est la suivante.
Tandis que la signature managée de XUserAddAsync est :
Voici un exemple d’appel des fonctions de XUserAddAsync en code natif.
Tandis que l’exemple managé d’appel des fonctions XUserAddAsync est :
Si vous préférez utiliser une file d’attente personnalisée, ou si l’API n’inclut pas d’implémentation de rappel, l’exemple suivant montre comment créer un XAsyncBlock. Vous devez également garantir la distribution et l’achèvement corrects de la file d’attente. Pour plus d’informations, consultez Vue d’ensemble de la bibliothèque XTaskQueue.

Exemple XblAchievementsUpdateAchievementAsync

La signature native de XblAchievementsUpdateAchievementAsync est la suivante.
Tandis que la signature managée de XblAchievementsUpdateAchievementAsync est :
Voici un exemple d’appel des fonctions de XblAchievementsUpdateAchievementAsync en code natif.
Tandis que l’exemple managé d’appel des fonctions XblAchievementsUpdateAchievementAsync est :

Initialisation de l’API XBOX Services (XSAPI) en code managé

À titre de référence, voici une initialisation de XSAPI en code managé. Voici la signature XSAPI en code managé.
Voici un exemple du modèle d’appel XSAPI en code managé.

Liste des API du Microsoft Game Development Kit (GDK) dans les wrappers managés

Les API du Microsoft Game Development Kit (GDK) suivantes sont incluses dans les wrappers managés du package GDK pour Unity. Pour plus d’informations sur les API du Microsoft Game Development Kit (GDK), consultez Référence des API système.
  • 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

Liste des API des XBOX services dans les wrappers managés

Les API des XBOX services suivantes sont incluses dans les wrappers managés du package GDK pour Unity. Pour plus d’informations sur les API des XBOX services, consultez Référence des API XBOX Live.

Documentation de référence des API

Voir aussi

Bien démarrer avec Unity pour le développement PC
Last modified on October 6, 2026