SpatialMeshObserver not showing up
Describe the bug
I'm trying to show the spatial mesh, so the user can calibrate my App. Using MRTK 2.1 and HoloLens 1, I was able to do that with:
private void ToggleSpatialAwarenes(bool _active)
{
if (MixedRealityServiceRegistry.TryGetService<IMixedRealitySpatialAwarenessSystem>(out var service))
{
IMixedRealityDataProviderAccess dataProviderAccess = service as IMixedRealityDataProviderAccess;
IMixedRealitySpatialAwarenessMeshObserver observer = dataProviderAccess.GetDataProvider<IMixedRealitySpatialAwarenessMeshObserver>();
observer.DisplayOption = _active ? SpatialAwarenessMeshDisplayOptions.Visible : SpatialAwarenessMeshDisplayOptions.None;
}
}
Now I'm using HoloLens 2 with MRTK 2.2 and the docs say I should do:
private void ToggleSpatialAwarenes(bool _active)
{
var access = CoreServices.SpatialAwarenessSystem as MixedRealityDataProviderAccess;
var observer = access.GetDataProvider<IMixedRealitySpatialAwarenessMeshObserver>();
if (_active)
{
CoreServices.SpatialAwarenessSystem.ResumeObservers();
observer.DisplayOption = SpatialAwarenessMeshDisplayOptions.Visible;
} else {
observer.DisplayOption = SpatialAwarenessMeshDisplayOptions.None;
CoreServices.SpatialAwarenessSystem.SuspendObservers();
}
}
I cloned the Default Profiles, but did not change any values. I can't see the mesh and neither do my handrays collide with it.
Setup:
- Unity Version 2019.2.11f1
- MRTK Version 2.2
Target platform:
- HoloLens 2
Found it: You have to manually enable Spatial Perception in the Package.appxmanifest (Visual Studio). The capability settings set in the Player Settings are overwritten, it seems.
The capability settings set in the Player Settings are overwritten, it seems.
I think if you've built the solution before the capability is set in the Player Settings, the appxmanifest doesn't update from the original settings, even after rebuilding unless the solution is deleted. That might be what you hit