对于SpherePointer,我有一个与this类似的问题。
使用NuGet for Unity收购的MRTK 2.2,我几乎在每一帧都收到此警告:
Maximum number of 64 colliders found in SpherePointer overlap query. Consider increasing the query buffer size in the pointer profile.
UnityEngine.Debug:LogWarning(Object)
Microsoft.MixedReality.Toolkit.Input.SpherePointerQueryInfo:TryUpdateQueryBufferForLayerMask(LayerMask, Vector3, QueryTriggerInteraction)
Microsoft.MixedReality.Toolkit.Input.SpherePointer:OnPreSceneQuery()
Microsoft.MixedReality.Toolkit.Input.FocusProvider:UpdatePointer(PointerData)
Microsoft.MixedReality.Toolkit.Input.FocusProvider:UpdatePointers()
Microsoft.MixedReality.Toolkit.Input.FocusProvider:Update()
Microsoft.MixedReality.Toolkit.<>c:<UpdateAllServices>b__63_0(IMixedRealityService)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:ExecuteOnAllServices(IEnumerable`1, Action`1)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:ExecuteOnAllServicesInOrder(Action`1)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:UpdateAllServices()
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:Update()
我能够使用@Julia's响应成功删除PokePointer的类似警告,但是我对如何在GrabPointer预制件上做到这一点感到困惑。
此预制件已附加SpherePointer脚本,但不会在检查器中显示SceneQueryBufferSize属性,因为SpherePointer的自定义检查器(ShperePointerInspector.cs)无法公开它。
答案 0 :(得分:0)
好问题!看来您实际上已经发现了一个错误。请暂时使用以下代码解决此问题,我们将在短期内发布修复程序。跟踪此问题的位置在这里:issue 6878
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using Microsoft.MixedReality.Toolkit.Input.Editor;
using Microsoft.MixedReality.Toolkit.Input;
using UnityEditor;
namespace Microsoft.MixedReality.Toolkit.Input
{
[CustomEditor(typeof(SpherePointer))]
public class SpherePointerInspector : BaseControllerPointerInspector
{
private SerializedProperty sphereCastRadius;
private SerializedProperty nearObjectMargin;
private SerializedProperty grabLayerMasks;
private SerializedProperty triggerInteraction;
private SerializedProperty sceneQueryBufferSize;
private bool spherePointerFoldout = true;
protected override void OnEnable()
{
base.OnEnable();
sphereCastRadius = serializedObject.FindProperty("sphereCastRadius");
sceneQueryBufferSize = serializedObject.FindProperty("sceneQueryBufferSize");
nearObjectMargin = serializedObject.FindProperty("nearObjectMargin");
grabLayerMasks = serializedObject.FindProperty("grabLayerMasks");
triggerInteraction = serializedObject.FindProperty("triggerInteraction");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
spherePointerFoldout = EditorGUILayout.Foldout(spherePointerFoldout, "Sphere Pointer Settings", true);
if (spherePointerFoldout)
{
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(sphereCastRadius);
EditorGUILayout.PropertyField(sceneQueryBufferSize);
EditorGUILayout.PropertyField(nearObjectMargin);
EditorGUILayout.PropertyField(triggerInteraction);
EditorGUILayout.PropertyField(grabLayerMasks, true);
}
}
serializedObject.ApplyModifiedProperties();
}
}
}
答案 1 :(得分:0)
感谢朱莉娅
由于我无法在项目中修改SpherePointerInspector.cs,因为MRTK是从NuGet获取的,并且没有实际的.cs文件可编辑。这是我在MRTK 2.3发布之前作为临时解决方案提出的解决方案。
我在GrabPointer.prefab的副本上用MySpherePointer.cs替换了SpherePointer.cs。
MySpherePointer.cs
using Microsoft.MixedReality.Toolkit.Input;
/// <summary>
/// This class exists soley to expose SpherePointer.queryBufferPointerSize which is
/// masked by the default SpherePointerInspector.
/// </summary>
public class MySpherePointer : SpherePointer
{
}
MySpherePointerInspector.cs
using Microsoft.MixedReality.Toolkit.Input;
using UnityEditor;
/// <summary>
/// This class exists soley to expose SpherePointer.queryBufferPointerSize which is
/// masked by the default SpherePointerInspector.
/// </summary>
[CustomEditor(typeof(MySpherePointer))]
public class MySpherePointerInspector : SpherePointerInspector
{
private SerializedProperty sceneQueryBufferSize;
private bool hiddenSpherePointerFoldout = true;
protected override void OnEnable()
{
base.OnEnable();
sceneQueryBufferSize = serializedObject.FindProperty("sceneQueryBufferSize");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
hiddenSpherePointerFoldout = EditorGUILayout.Foldout(hiddenSpherePointerFoldout, "Hidden Sphere Pointer Settings", true);
if (hiddenSpherePointerFoldout)
{
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(sceneQueryBufferSize);
}
}
serializedObject.ApplyModifiedProperties();
}
}