在运行时在MRTK2中启用/禁用空间映射 [英] Enable/Disable Spatial Mapping at runtime in MRTK2

查看:164
本文介绍了在运行时在MRTK2中启用/禁用空间映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于新的MRTK2,我希望在完成将其放置到GameObjects后禁用其空间映射.我被困在运行时在名称空间或服务中要执行的操作.

With the new MRTK2 I'm looking to disable spatial mapping after we are done using it to place GameObjects. I'm stuck on what exactly to call in the namespace or on the service to do this at run time.

我尝试过:MixedRealityToolkit.SpatialAwarenessSystem.SuspendObservers(); 这没有作用.我可以禁用整个空间感知系统" GameObject,但这将是一个hack.

I've tried: MixedRealityToolkit.SpatialAwarenessSystem.SuspendObservers(); This has no effect. I could disable the entire "Spatial Awareness System" GameObject, but this would be a hack.

我需要的是适当的调用,该调用将完全禁用系统,以便在不再有用时释放资源?

What I need is the proper call that would disable the system entirely so that resources are freed up when it is no longer useful?

此外,对我们如何正确访问服务系统的一些见解将有很大帮助.

Additionally, a little insight into how we are to access the service system correctly would be of great help.

推荐答案

您可以使用以下代码来禁用/启用空间感知系统:

You can use the following code to disable/enable the spatial awareness system:

if (disable)
{
    // disable
    MixedRealityToolkit.SpatialAwarenessSystem.Disable();
}
else
{
    // enable
    MixedRealityToolkit.SpatialAwarenessSystem.Enable()
}

您可以使用以下代码仅启用/禁用可视化,但保持对撞机处于打开状态:

You can use the following code to enable/disable just the visualization but keep the colliders on:

foreach(var observer in MixedRealityToolkit.SpatialAwarenessSystem.GetObservers())
{
    var meshObserver = observer as IMixedRealitySpatialAwarenessMeshObserver;
    if (meshObserver != null)
    {
        meshObserver.DisplayOption = SpatialAwarenessMeshDisplayOptions.None;
    }
}

您可以在 mrtk github.io网站上阅读有关MRTK中的空间感知系统的更多文档 空间感知系统使用指南

这篇关于在运行时在MRTK2中启用/禁用空间映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆