我相信这归结为 InteractionManager 没有在应用程序进入 shell 时为视图中的手引发源丢失事件。统一错误:https ://fogbugz.unity3d.com/default.asp?1162545_9ee6crevf35hsbl5
作为一种解决方法,您可以尝试将以下代码添加到 WindowsMixedRealityDeviceManager 以在应用程序失去焦点时清除现有控制器。请记住,这将导致 WMR 设备出现问题,因为当您移除耳机但 6 个 DOF 控制器仍然存在时,应用程序会失去焦点,因此它们将被清除并且永远不会重新获得。
public override void Enable()
{
// ...
#if !UNITY_EDITOR
Application.focusChanged += OnFocusChanged;
#endif
}
public override void Disable()
{
#if !UNITY_EDITOR
Application.focusChanged -= OnFocusChanged;
#endif
// ...
}
#if !UNITY_EDITOR
private void OnFocusChanged(bool focus)
{
// Remove all active controllers when losing focus
if (!focus && !Application.runInBackground)
{
IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem;
foreach (var keyValue in activeControllers)
{
var controller = keyValue.Value as BaseWindowsMixedRealitySource;
if (controller != null)
{
inputSystem?.RaiseSourceLost(controller.InputSource, controller);
foreach (IMixedRealityPointer pointer in controller.InputSource.Pointers)
{
if (pointer != null)
{
pointer.Controller = null;
}
}
}
}
activeControllers.Clear();
}
}
#endif // !UNITY_EDITOR