首页 > 解决方案 > Unity 中用于 MRTKv2/Hololens2 的 2D 屏幕叠加

问题描述

我想在 Hololens2 上使用 Unity 制作 2D 屏幕叠加层。我创建了一个 Unity Canvas 设置为“屏幕空间 - 相机”渲染模式,并尝试将 MRTK 提供的相机添加为渲染相机。这导致了以下错误:

TargetParameterCountException: Number of parameters specified does not match the expected number.
System.Reflection.MonoMethod.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <567df3e0919241ba98db88bec4c6696f>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <567df3e0919241ba98db88bec4c6696f>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <567df3e0919241ba98db88bec4c6696f>:0)
Microsoft.MixedReality.Toolkit.Input.MixedRealityCanvasInspector.AllRootCanvases () (at Assets/MixedRealityToolkit.Services/InputSystem/Editor/MixedRealityCanvasInspector.cs:206)
Microsoft.MixedReality.Toolkit.Input.MixedRealityCanvasInspector.OnInspectorGUI () (at Assets/MixedRealityToolkit.Services/InputSystem/Editor/MixedRealityCanvasInspector.cs:334)
UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:501)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

我不知道这是一个错误还是有意为之。我目前的解决方法是计算世界空间位置和相机前覆盖的尺寸。

有什么简单的方法可以让 Hololens2 渲染 2D 屏幕叠加层?

标签: unity3dhololensmrtk

解决方案


推荐阅读