传送系统 - MRTK2

传送系统是 MRTK 的子系统,在应用程序使用不透明显示时处理传送用户。 对于 ar 体验 ((如 HoloLens) ),传送系统不处于活动状态。 对于 (OpenVR 的沉浸式 HMD 体验,可以启用传送系统的 WMR) 。

启用和禁用

可以通过切换传送系统配置文件中的复选框来启用或禁用传送系统。 为此,可以选择场景中的 MixedRealityToolkit 对象,单击“Teleport”,然后切换“启用传送系统”复选框。

这也可以在运行时完成:

void DisableTeleportSystem()
{
    CoreServices.TeleportSystem.Disable();
}

void EnableTeleportSystem()
{
    CoreServices.TeleportSystem.Enable();
}

事件

传送系统通过 接口公开事件, IMixedRealityTeleportHandler 以在传送作开始、结束或取消时提供信号。 有关事件机制及其关联有效负载的更多详细信息,请参阅链接的 API 文档。

用法

如何注册传送事件

下面的代码演示如何创建将侦听传送事件的 MonoBehaviour。 此代码假定已启用传送系统。

using Microsoft.MixedReality.Toolkit;
using Microsoft.MixedReality.Toolkit.Teleport;
using UnityEngine;

public class TeleportHandlerExample : MonoBehaviour, IMixedRealityTeleportHandler
{
    public void OnTeleportCanceled(TeleportEventData eventData)
    {
        Debug.Log("Teleport Cancelled");
    }

    public void OnTeleportCompleted(TeleportEventData eventData)
    {
        Debug.Log("Teleport Completed");
    }

    public void OnTeleportRequest(TeleportEventData eventData)
    {
        Debug.Log("Teleport Request");
    }

    public void OnTeleportStarted(TeleportEventData eventData)
    {
        Debug.Log("Teleport Started");
    }

    void OnEnable()
    {
        // This is the critical call that registers this class for events. Without this
        // class's IMixedRealityTeleportHandler interface will not be called.
        CoreServices.TeleportSystem.RegisterHandler<IMixedRealityTeleportHandler>(this);
    }

    void OnDisable()
    {
        // Unregistering when disabled is important, otherwise this class will continue
        // to receive teleportation events.
        CoreServices.TeleportSystem.UnregisterHandler<IMixedRealityTeleportHandler>(this);
    }
}

MRTK 上的传送

若要在具有默认配置的 MR 设备上使用控制器传送,请使用纵杆。 若要用关节手传送传送,请做出手势,手掌朝上,索引和拇指向外粘附,通过卷曲食指来完成传送。 若要使用输入模拟传送,请参阅更新的 输入模拟服务文档

传送手势