microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6.01k stars 2.12k forks source link

DotNetWinRT not supporting SpatialAnchor #9542

Closed qian256 closed 3 years ago

qian256 commented 3 years ago

Describe the problem

The DotNetWinRT package is said to support Windows.Spatial.Perception namespace (https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/using-the-windows-namespace-with-unity-apps-for-hololens) but it looks like it does not include SpatialAnchor related APIs. As a result, it is not possible to call SpatialAnchor APIs in Unity editor just hitting "Play".

On the other hand, when I inspect the NuGet DotNetWinRT package, the XML file listed the SpatialAnchor API, which is very weird.

Although this is not directly related to MRTK, but I couldn't find a better place than here to post this request. Thanks!

Describe the solution you'd like

Extend the DotNetWinRT API to include SpatialAnchor

Describe alternatives you've considered

Is there any other workaround that we could do to use SpatialAnchor in editor mode?

david-c-kline commented 3 years ago

thanks @qian256 ! I will forward to the correct people

dfields-msft commented 3 years ago

@qian256 thanks for raising this issue! The API coverage is a bit piecemeal, driven by scenario requirements, and we haven't had a need to support SpatialAnchor so far since Unity provides the XRAnchor API for this (or ARAnchor if you're using ARFoundation). Could you provide some additional context and details on your scenario for using the native SpatialAnchor APIs directly?

qian256 commented 3 years ago

In our scenario, we don't use Unity ARSubsyustem or ARFoundation. The API that we find in Unity is UnityEngine.XR.WSA.WorldAnchor, which behaves weird on HoloLens. e.g. it does not show up in the anchorstore. So we sticked to the UWP SpatialAnchor API. As a result, it does not work in editor.

keveleigh commented 3 years ago

Hey @qian256! Can you clarify the Unity version and XR package you're using please?

qian256 commented 3 years ago

Unity 2019.3.12f1 and legacy XR

keveleigh commented 3 years ago

The API that we find in Unity is UnityEngine.XR.WSA.WorldAnchor, which behaves weird on HoloLens. e.g. it does not show up in the anchorstore.

This would be very surprising and a definite regression. Were you using the WorldAnchorStore API to save it in the anchor store?

qian256 commented 3 years ago

Could I email you for further discussion? Our usecase is probably rare. The WorldAnchor works in almost all cases.

MaxWang-MS commented 3 years ago

Please reopen the issue if you are still encountering it.