如何修改 GrabPointer 预制件以允许场景中超过默认的 64 个碰撞器?
How do I modify the GrabPointer prefab to allow for more than the default 64 colliders in a scene?
我有一个与 this 类似的问题,但是对于 SpherePointer。
使用 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) 未公开它。
好问题!看起来你真的发现了一个错误。请暂时使用以下代码解决此问题,我们将很快 post 进行修复。跟踪这个的问题在这里: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();
}
}
}
谢谢朱莉娅,
因为我无法在我的项目中修改 SpherePointerInspector.cs,因为 MRTK 是从 NuGet 获得的,没有实际的 .cs 文件可以编辑。这是我在 MRTK 2.3 发布之前作为临时解决方法提出的解决方案。
我在 GrabPointer.prefab 的副本上用我的 SpherePointer.cs 替换了 SpherePointer.cs。
我的SpherePointer.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
{
}
我的SpherePointerInspector.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();
}
}
我有一个与 this 类似的问题,但是对于 SpherePointer。
使用 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) 未公开它。
好问题!看起来你真的发现了一个错误。请暂时使用以下代码解决此问题,我们将很快 post 进行修复。跟踪这个的问题在这里: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();
}
}
}
谢谢朱莉娅,
因为我无法在我的项目中修改 SpherePointerInspector.cs,因为 MRTK 是从 NuGet 获得的,没有实际的 .cs 文件可以编辑。这是我在 MRTK 2.3 发布之前作为临时解决方法提出的解决方案。
我在 GrabPointer.prefab 的副本上用我的 SpherePointer.cs 替换了 SpherePointer.cs。
我的SpherePointer.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
{
}
我的SpherePointerInspector.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();
}
}