Skip to content

Commit b64c208

Browse files
authored
[Samples] Increase pen interactor collider size to improve usability (#1018)
Increase pen interactor collider to improve usability
1 parent 7d08495 commit b64c208

3 files changed

Lines changed: 69 additions & 61 deletions

File tree

UnityProjects/MRTKDevTemplate/Assets/Prefabs/Whiteboard/pen.prefab

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GameObject:
1010
m_Component:
1111
- component: {fileID: 2002339756}
1212
- component: {fileID: 2002339758}
13-
- component: {fileID: 2002339757}
13+
- component: {fileID: 1066413309105225662}
1414
- component: {fileID: 2002339759}
1515
m_Layer: 0
1616
m_Name: Pen Interactor
@@ -26,13 +26,13 @@ Transform:
2626
m_PrefabInstance: {fileID: 0}
2727
m_PrefabAsset: {fileID: 0}
2828
m_GameObject: {fileID: 2002339755}
29+
serializedVersion: 2
2930
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
3031
m_LocalPosition: {x: 0, y: 0, z: -0.0123}
3132
m_LocalScale: {x: 1, y: 1, z: 1}
3233
m_ConstrainProportionsScale: 0
3334
m_Children: []
3435
m_Father: {fileID: 2415827607033482817}
35-
m_RootOrder: 0
3636
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
3737
--- !u!114 &2002339758
3838
MonoBehaviour:
@@ -47,11 +47,9 @@ MonoBehaviour:
4747
m_Name:
4848
m_EditorClassIdentifier:
4949
m_InteractionManager: {fileID: 0}
50-
m_InteractionLayerMask:
51-
serializedVersion: 2
52-
m_Bits: 4294967295
5350
m_InteractionLayers:
5451
m_Bits: 4294967295
52+
m_Handedness: 0
5553
m_AttachTransform: {fileID: 0}
5654
m_KeepSelectedTargetValid: 1
5755
m_DisableVisualsWhenBlockedInGroup: 1
@@ -71,42 +69,51 @@ MonoBehaviour:
7169
m_Calls: []
7270
m_StartingHoverFilters: []
7371
m_StartingSelectFilters: []
74-
m_OnHoverEntered:
75-
m_PersistentCalls:
76-
m_Calls: []
77-
m_OnHoverExited:
78-
m_PersistentCalls:
79-
m_Calls: []
80-
m_OnSelectEntered:
81-
m_PersistentCalls:
82-
m_Calls: []
83-
m_OnSelectExited:
84-
m_PersistentCalls:
85-
m_Calls: []
86-
--- !u!135 &2002339757
87-
SphereCollider:
72+
--- !u!136 &1066413309105225662
73+
CapsuleCollider:
8874
m_ObjectHideFlags: 0
8975
m_CorrespondingSourceObject: {fileID: 0}
9076
m_PrefabInstance: {fileID: 0}
9177
m_PrefabAsset: {fileID: 0}
9278
m_GameObject: {fileID: 2002339755}
9379
m_Material: {fileID: 0}
80+
m_IncludeLayers:
81+
serializedVersion: 2
82+
m_Bits: 0
83+
m_ExcludeLayers:
84+
serializedVersion: 2
85+
m_Bits: 0
86+
m_LayerOverridePriority: 0
9487
m_IsTrigger: 1
88+
m_ProvidesContacts: 0
9589
m_Enabled: 1
9690
serializedVersion: 2
9791
m_Radius: 0.0005
98-
m_Center: {x: 0, y: 0, z: 0.0004}
92+
m_Height: 0.003
93+
m_Direction: 2
94+
m_Center: {x: 0, y: 0, z: 0.0008}
9995
--- !u!54 &2002339759
10096
Rigidbody:
10197
m_ObjectHideFlags: 0
10298
m_CorrespondingSourceObject: {fileID: 0}
10399
m_PrefabInstance: {fileID: 0}
104100
m_PrefabAsset: {fileID: 0}
105101
m_GameObject: {fileID: 2002339755}
106-
serializedVersion: 2
102+
serializedVersion: 4
107103
m_Mass: 1
108104
m_Drag: 0
109105
m_AngularDrag: 0.05
106+
m_CenterOfMass: {x: 0, y: 0, z: 0}
107+
m_InertiaTensor: {x: 1, y: 1, z: 1}
108+
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
109+
m_IncludeLayers:
110+
serializedVersion: 2
111+
m_Bits: 0
112+
m_ExcludeLayers:
113+
serializedVersion: 2
114+
m_Bits: 0
115+
m_ImplicitCom: 1
116+
m_ImplicitTensor: 1
110117
m_UseGravity: 1
111118
m_IsKinematic: 1
112119
m_Interpolate: 0
@@ -140,14 +147,14 @@ Transform:
140147
m_PrefabInstance: {fileID: 0}
141148
m_PrefabAsset: {fileID: 0}
142149
m_GameObject: {fileID: 3084243108605482235}
150+
serializedVersion: 2
143151
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
144152
m_LocalPosition: {x: -0, y: 0, z: 0.333}
145153
m_LocalScale: {x: 8, y: 8, z: 8}
146154
m_ConstrainProportionsScale: 0
147155
m_Children:
148156
- {fileID: 2002339756}
149157
m_Father: {fileID: 0}
150-
m_RootOrder: 0
151158
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
152159
--- !u!33 &1596919684305715684
153160
MeshFilter:
@@ -209,8 +216,17 @@ CapsuleCollider:
209216
m_PrefabAsset: {fileID: 0}
210217
m_GameObject: {fileID: 3084243108605482235}
211218
m_Material: {fileID: 0}
219+
m_IncludeLayers:
220+
serializedVersion: 2
221+
m_Bits: 0
222+
m_ExcludeLayers:
223+
serializedVersion: 2
224+
m_Bits: 0
225+
m_LayerOverridePriority: 0
212226
m_IsTrigger: 0
227+
m_ProvidesContacts: 0
213228
m_Enabled: 1
229+
serializedVersion: 2
214230
m_Radius: 0.0015
215231
m_Height: 0.025
216232
m_Direction: 2
@@ -229,13 +245,11 @@ MonoBehaviour:
229245
m_EditorClassIdentifier:
230246
m_InteractionManager: {fileID: 0}
231247
m_Colliders: []
232-
m_InteractionLayerMask:
233-
serializedVersion: 2
234-
m_Bits: 4294967295
235248
m_InteractionLayers:
236249
m_Bits: 1
237250
m_DistanceCalculationMode: 1
238251
m_SelectMode: 0
252+
m_FocusMode: 1
239253
m_CustomReticle: {fileID: 0}
240254
m_AllowGazeInteraction: 0
241255
m_AllowGazeSelect: 0
@@ -268,42 +282,27 @@ MonoBehaviour:
268282
m_SelectExited:
269283
m_PersistentCalls:
270284
m_Calls: []
271-
m_Activated:
272-
m_PersistentCalls:
273-
m_Calls: []
274-
m_Deactivated:
275-
m_PersistentCalls:
276-
m_Calls: []
277-
m_StartingHoverFilters: []
278-
m_StartingSelectFilters: []
279-
m_StartingInteractionStrengthFilters: []
280-
m_OnFirstHoverEntered:
281-
m_PersistentCalls:
282-
m_Calls: []
283-
m_OnLastHoverExited:
284-
m_PersistentCalls:
285-
m_Calls: []
286-
m_OnHoverEntered:
287-
m_PersistentCalls:
288-
m_Calls: []
289-
m_OnHoverExited:
285+
m_FirstFocusEntered:
290286
m_PersistentCalls:
291287
m_Calls: []
292-
m_OnSelectEntered:
288+
m_LastFocusExited:
293289
m_PersistentCalls:
294290
m_Calls: []
295-
m_OnSelectExited:
291+
m_FocusEntered:
296292
m_PersistentCalls:
297293
m_Calls: []
298-
m_OnSelectCanceled:
294+
m_FocusExited:
299295
m_PersistentCalls:
300296
m_Calls: []
301-
m_OnActivate:
297+
m_Activated:
302298
m_PersistentCalls:
303299
m_Calls: []
304-
m_OnDeactivate:
300+
m_Deactivated:
305301
m_PersistentCalls:
306302
m_Calls: []
303+
m_StartingHoverFilters: []
304+
m_StartingSelectFilters: []
305+
m_StartingInteractionStrengthFilters: []
307306
isGazePinchSelected:
308307
active: 0
309308
onEntered:
@@ -418,6 +417,7 @@ MonoBehaviour:
418417
hostTransform: {fileID: 2415827607033482817}
419418
allowedManipulations: 3
420419
allowedInteractionTypes: 1
420+
rigidbodyMovementType: 0
421421
applyTorque: 1
422422
springForceSoftness: 0.1
423423
springTorqueSoftness: 0.1
@@ -440,8 +440,7 @@ MonoBehaviour:
440440
moveLogicType:
441441
reference: MixedReality.Toolkit.SpatialManipulation.MoveLogic, MixedReality.Toolkit.SpatialManipulation
442442
rotateLogicType:
443-
reference: MixedReality.Toolkit.SpatialManipulation.RotateLogic,
444-
MixedReality.Toolkit.SpatialManipulation
443+
reference: MixedReality.Toolkit.SpatialManipulation.RotateLogic, MixedReality.Toolkit.SpatialManipulation
445444
scaleLogicType:
446445
reference: MixedReality.Toolkit.SpatialManipulation.ScaleLogic, MixedReality.Toolkit.SpatialManipulation
447446
--- !u!114 &2741574062440155178

UnityProjects/MRTKDevTemplate/Assets/Scripts/Editor/AndroidXRConfig.cs.meta

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityProjects/MRTKDevTemplate/Assets/Scripts/PenInteractor.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright (c) Mixed Reality Toolkit Contributors
22
// Licensed under the BSD 3-Clause
33

4-
// Disable "missing XML comment" warning for samples. While nice to have, this XML documentation is not required for samples.
5-
#pragma warning disable CS1591
6-
74
using System.Collections.Generic;
85
using UnityEngine;
96
using UnityEngine.XR.Interaction.Toolkit;
@@ -38,14 +35,14 @@ internal class PenInteractor : XRBaseInteractor, IPokeInteractor
3835
#region IPokeInteractor Implementation
3936

4037
/// <inheritdoc />
41-
public float PokeRadius => 0.001f;
38+
float IPokeInteractor.PokeRadius => 0.001f;
4239

4340
// The last and current poke points, forming a
4441
// continuous poking trajectory.
4542
private PokePath pokeTrajectory;
4643

4744
/// <inheritdoc />
48-
public PokePath PokeTrajectory => pokeTrajectory;
45+
PokePath IPokeInteractor.PokeTrajectory => pokeTrajectory;
4946

5047
#endregion IPokeInteractor Implementation
5148

@@ -86,9 +83,13 @@ public override void ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase upda
8683
}
8784
}
8885

89-
void OnTriggerStay(Collider c)
86+
/// <summary>
87+
/// OnTriggerStay is called once per physics update for every Collider <paramref name="other"/> that is touching the trigger.
88+
/// </summary>
89+
/// <param name="other">The other Collider involved in this collision.</param>
90+
protected void OnTriggerStay(Collider other)
9091
{
91-
if (interactionManager.TryGetInteractableForCollider(c, out var associatedInteractable))
92+
if (interactionManager.TryGetInteractableForCollider(other, out IXRInteractable associatedInteractable))
9293
{
9394
hoveredTargets.Add(associatedInteractable);
9495
}
@@ -97,10 +98,9 @@ void OnTriggerStay(Collider c)
9798
/// <summary>
9899
/// A Unity event function that is called at an framerate independent frequency, and is only called if this object is enabled.
99100
/// </summary>
100-
private void FixedUpdate()
101+
protected void FixedUpdate()
101102
{
102103
hoveredTargets.Clear();
103104
}
104105
}
105106
}
106-
#pragma warning restore CS1591

0 commit comments

Comments
 (0)