@@ -22,6 +22,7 @@ public class ControllerInteraction : MonoBehaviour
22
22
23
23
public Transform handJointPrefab ;
24
24
private bool handJointsVisible = false ;
25
+ [ SerializeField ] private bool useCollidersForHandJoints = true ;
25
26
26
27
[ SerializeField ] private bool useInputProfile = true ;
27
28
@@ -155,6 +156,37 @@ private void OnTriggerExit(Collider other)
155
156
contactRigidBodies . Remove ( other . gameObject . GetComponent < Rigidbody > ( ) ) ;
156
157
}
157
158
159
+ public void SetUseCollidersForHandJoints ( bool value )
160
+ {
161
+ useCollidersForHandJoints = value ;
162
+ for ( int i = 0 ; i <= ( int ) WebXRHandJoint . pinky_finger_tip ; i ++ )
163
+ {
164
+ if ( handJoints . ContainsKey ( i ) )
165
+ {
166
+ var collider = handJoints [ i ] . GetComponent < Collider > ( ) ;
167
+ if ( collider != null )
168
+ {
169
+ collider . enabled = useCollidersForHandJoints ;
170
+ }
171
+ }
172
+ #if WEBXR_INPUT_PROFILES
173
+ if ( handModelJoints . ContainsKey ( i ) )
174
+ {
175
+ var collider = handModelJoints [ i ] . GetComponent < Collider > ( ) ;
176
+ if ( collider != null )
177
+ {
178
+ collider . enabled = useCollidersForHandJoints ;
179
+ }
180
+ }
181
+ #endif
182
+ }
183
+ }
184
+
185
+ public bool GetUseCollidersForHandJoints ( )
186
+ {
187
+ return useCollidersForHandJoints ;
188
+ }
189
+
158
190
public void SetUseInputProfile ( bool value )
159
191
{
160
192
useInputProfile = value ;
@@ -290,6 +322,11 @@ private void OnHandUpdate(WebXRHandData handData)
290
322
{
291
323
clone . localScale = new Vector3 ( 0.005f , 0.005f , 0.005f ) ;
292
324
}
325
+ var collider = clone . GetComponent < Collider > ( ) ;
326
+ if ( collider != null )
327
+ {
328
+ collider . enabled = useCollidersForHandJoints ;
329
+ }
293
330
handJoints . Add ( i , clone ) ;
294
331
handJointsVisuals [ i ] = clone . gameObject ;
295
332
}
@@ -413,9 +450,12 @@ private void HandleHandModelLoaded(bool success)
413
450
if ( handJoints . ContainsKey ( i ) )
414
451
{
415
452
handModelJoints [ i ] . SetPositionAndRotation ( handJoints [ i ] . position , handJoints [ i ] . rotation ) ;
416
- var collider = handModelJoints [ i ] . gameObject . AddComponent < SphereCollider > ( ) ;
417
- collider . radius = handJoints [ i ] . localScale . x ;
418
- collider . isTrigger = true ;
453
+ if ( useCollidersForHandJoints )
454
+ {
455
+ var collider = handModelJoints [ i ] . gameObject . AddComponent < SphereCollider > ( ) ;
456
+ collider . radius = handJoints [ i ] . localScale . x ;
457
+ collider . isTrigger = true ;
458
+ }
419
459
}
420
460
}
421
461
if ( handJointsVisible )
0 commit comments