在MRTK中使用空间感知(也称为空间映射)时,一个常见的问题是如何访问空间观察者以单独配置它们。
问题的出现是因为GetObserver接口的IMixedRealitySpatialAwarenessSystem方法被标记为过时了。
发布于 2019-09-12 19:38:12
版本2.0.0发布的MRTK已经标准化了跨服务访问数据提供者的模式,以便
下面的示例演示了访问空间感知网格观察者的模式。
if (CoreServices.SpatialAwarenessSystem != null)
{
IMixedRealityDataProviderAccess dataProviderAccess =
CoreServices.SpatialAwarenessSystem as IMixedRealityDataProviderAccess;
if (dataProviderAccess != null)
{
IReadOnlyList<IMixedRealitySpatialAwarenessMeshObserver> observers =
dataProviderAccess.GetDataProviders<IMixedRealitySpatialAwarenessMeshObserver>();
// Modify the observer(s)
foreach (IMixedRealitySpatialAwarenessMeshObserver observer in observers)
{
// Set the mesh to use the occlusion material
observer.DisplayOption = SpatialMeshDisplayOptions.Occlusion;
}
}
}https://stackoverflow.com/questions/57913479
复制相似问题