Search Issue Tracker




Found in [Package]


Issue ID




[XR] UnityEngine.XR.XRDevice.GetNativePtr() Always IntPtr.Zero with the new XR plugin system

Package: Windows XR Plugin


This issue has no description.

  1. Resolution Note:

    The old GetNativePtr mechanism provided by Legacy VR was a stopgap approach meant more to allow our platform partners the ability to get at information on their platforms that we couldn't or didn't expose through a common API. This pointer mechanism usually consisted of a blob of data that had to be cast and interpreted correctly by the user or bad things could happen. This was deemed not very maintainable.

    When we created the new XR SDK plugin system, a lot of what was exposed in that blob was pushed out into specific native pointer data for subsystems that allowed for a more semantic definition of the data as well as more explicit pointer definitions. You still have to cast the pointer, but it should be a specific pointer to a single instance of the underlying system type for the managed object in play.

    For instance: Anything that supports [ITrackable]( has a **nativePtr** field that is used to pass the native pointer to the platform underlying data for that thing.

    Example: [XRAnchorSubystem]( and Windows MR Plug-in provider

    For anchors with Windows MR as the provider, the native pointer field will be set to a pointer to the underlying (SpatialAnchor)[]. The benefit in this case is you can use that ptr directly using WinMD APIs to get data from it directly without reaching down to native code.

    You can find more info about the general AR APIs and where they provide native pointer information in the [AR Subsystems documentation](

    Where something general like that didn't make sense, or there was data specific to a platform that was not exposable at a common point, the provider for that platform should expose specific APIs for getting at the platform data.

    For Windows MR we have the following examples:

    SourceStates: (WindowsMRInput.GetCurrentSourceStates)[]. This returns a list of (WindowsMRInput.SourceState)[]. Each source state has a nativeState pointer that is an instance of a (SpatialAnchorSourceStates)[].

    Meshing Data:

    [WindowsMRExtensions.GetMeshingDataForMesh]( will return meshing information in a [WindowsMRExtensions.MeshingData]( structure for a given mesh id. The **MeshingData.surfaceInfo** and **MeshingData.surfaceMesh** which are (respectively) instances of [SpatialSurfaceInfo]( and (SpatialSurfaceMesh)[].

    You can find more info about these APIs for Windows MR in the [Windows MR Plug-in Documentation](

    All documentation pointed to here is also accessible from the package Documentation links from the Package Manager UI within Unity. This includes specific platform plug-ins that may be available but not talked about here.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.