Skip to content

Commit 068afdb

Browse files
committed
added pickup button configuration
1 parent 700808d commit 068afdb

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

Packages/webxr-interactions/Runtime/Prefabs/WebXRCameraSet.prefab

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Transform:
2727
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
2828
m_LocalPosition: {x: -0.032, y: 0, z: 0}
2929
m_LocalScale: {x: 1, y: 1, z: 1}
30+
m_ConstrainProportionsScale: 0
3031
m_Children: []
3132
m_Father: {fileID: 4414771795277364}
3233
m_RootOrder: 1
@@ -101,6 +102,7 @@ Transform:
101102
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
102103
m_LocalPosition: {x: 0.032, y: 0, z: 0}
103104
m_LocalScale: {x: 1, y: 1, z: 1}
105+
m_ConstrainProportionsScale: 0
104106
m_Children: []
105107
m_Father: {fileID: 4414771795277364}
106108
m_RootOrder: 2
@@ -175,6 +177,7 @@ Transform:
175177
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
176178
m_LocalPosition: {x: 0, y: 0, z: 0}
177179
m_LocalScale: {x: 1, y: 1, z: 1}
180+
m_ConstrainProportionsScale: 0
178181
m_Children:
179182
- {fileID: 4684771153913254}
180183
- {fileID: 4357122362856218}
@@ -230,6 +233,7 @@ Transform:
230233
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
231234
m_LocalPosition: {x: 0, y: 0, z: 0}
232235
m_LocalScale: {x: 1, y: 1, z: 1}
236+
m_ConstrainProportionsScale: 0
233237
m_Children:
234238
- {fileID: 4427160273819458}
235239
- {fileID: 4446684710817404}
@@ -280,6 +284,7 @@ Transform:
280284
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
281285
m_LocalPosition: {x: -0.25, y: 0.745, z: -0.541}
282286
m_LocalScale: {x: 1, y: 1, z: 1}
287+
m_ConstrainProportionsScale: 0
283288
m_Children:
284289
- {fileID: 4008237015318879989}
285290
- {fileID: 1218315907877956796}
@@ -311,6 +316,7 @@ FixedJoint:
311316
m_PrefabAsset: {fileID: 0}
312317
m_GameObject: {fileID: 1799026754646168}
313318
m_ConnectedBody: {fileID: 0}
319+
m_ConnectedArticulationBody: {fileID: 0}
314320
m_BreakForce: Infinity
315321
m_BreakTorque: Infinity
316322
m_EnableCollision: 0
@@ -347,12 +353,13 @@ MonoBehaviour:
347353
animationStateName:
348354
controllerVisuals:
349355
- {fileID: 3858442981242374931}
350-
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923,
351-
type: 3}
356+
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923, type: 3}
357+
useCollidersForHandJoints: 1
352358
useInputProfile: 1
353359
inputProfileObject: {fileID: 1611361787474004}
354360
inputProfileModelParent: {fileID: 1469228564561163144}
355361
inputProfileHandModelParent: {fileID: 3331348236738357118}
362+
grabButtons: 000000000100000004000000
356363
--- !u!114 &7185579886917944061
357364
MonoBehaviour:
358365
m_ObjectHideFlags: 0
@@ -399,6 +406,7 @@ Transform:
399406
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
400407
m_LocalPosition: {x: 0, y: 0, z: 0}
401408
m_LocalScale: {x: 1, y: 1, z: 1}
409+
m_ConstrainProportionsScale: 0
402410
m_Children: []
403411
m_Father: {fileID: 4414771795277364}
404412
m_RootOrder: 0
@@ -495,6 +503,7 @@ Transform:
495503
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
496504
m_LocalPosition: {x: 0.25, y: 0.74500006, z: -0.541}
497505
m_LocalScale: {x: 1, y: 1, z: 1}
506+
m_ConstrainProportionsScale: 0
498507
m_Children:
499508
- {fileID: 3110396931964762061}
500509
- {fileID: 3819867499605581648}
@@ -526,6 +535,7 @@ FixedJoint:
526535
m_PrefabAsset: {fileID: 0}
527536
m_GameObject: {fileID: 1986733487743170}
528537
m_ConnectedBody: {fileID: 0}
538+
m_ConnectedArticulationBody: {fileID: 0}
529539
m_BreakForce: Infinity
530540
m_BreakTorque: Infinity
531541
m_EnableCollision: 0
@@ -562,12 +572,13 @@ MonoBehaviour:
562572
animationStateName:
563573
controllerVisuals:
564574
- {fileID: 2954843634523120171}
565-
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923,
566-
type: 3}
575+
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923, type: 3}
576+
useCollidersForHandJoints: 1
567577
useInputProfile: 1
568578
inputProfileObject: {fileID: 1611361787474004}
569579
inputProfileModelParent: {fileID: 599836867309221058}
570580
inputProfileHandModelParent: {fileID: 8661450511316122934}
581+
grabButtons: 000000000100000004000000
571582
--- !u!114 &1966769163579045322
572583
MonoBehaviour:
573584
m_ObjectHideFlags: 0
@@ -613,6 +624,7 @@ Transform:
613624
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
614625
m_LocalPosition: {x: 0, y: 0, z: 0}
615626
m_LocalScale: {x: 1, y: 1, z: 1}
627+
m_ConstrainProportionsScale: 0
616628
m_Children: []
617629
m_Father: {fileID: 4446684710817404}
618630
m_RootOrder: 1
@@ -657,6 +669,7 @@ Transform:
657669
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
658670
m_LocalPosition: {x: 0, y: 0, z: 0}
659671
m_LocalScale: {x: 1, y: 1, z: 1}
672+
m_ConstrainProportionsScale: 0
660673
m_Children: []
661674
m_Father: {fileID: 4427160273819458}
662675
m_RootOrder: 1
@@ -703,6 +716,7 @@ Transform:
703716
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
704717
m_LocalPosition: {x: 0, y: 0, z: 0}
705718
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
719+
m_ConstrainProportionsScale: 0
706720
m_Children: []
707721
m_Father: {fileID: 4446684710817404}
708722
m_RootOrder: 0
@@ -726,10 +740,12 @@ MeshRenderer:
726740
m_CastShadows: 1
727741
m_ReceiveShadows: 1
728742
m_DynamicOccludee: 1
743+
m_StaticShadowCaster: 0
729744
m_MotionVectors: 1
730745
m_LightProbeUsage: 1
731746
m_ReflectionProbeUsage: 1
732747
m_RayTracingMode: 2
748+
m_RayTraceProcedural: 0
733749
m_RenderingLayerMask: 1
734750
m_RendererPriority: 0
735751
m_Materials:
@@ -754,6 +770,7 @@ MeshRenderer:
754770
m_SortingLayerID: 0
755771
m_SortingLayer: 0
756772
m_SortingOrder: 0
773+
m_AdditionalVertexStreams: {fileID: 0}
757774
--- !u!65 &4365337428889893541
758775
BoxCollider:
759776
m_ObjectHideFlags: 0
@@ -794,6 +811,7 @@ Transform:
794811
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
795812
m_LocalPosition: {x: 0, y: 0, z: 0}
796813
m_LocalScale: {x: 1, y: 1, z: 1}
814+
m_ConstrainProportionsScale: 0
797815
m_Children: []
798816
m_Father: {fileID: 4414771795277364}
799817
m_RootOrder: 3
@@ -867,6 +885,7 @@ Transform:
867885
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
868886
m_LocalPosition: {x: 0, y: 0, z: 0}
869887
m_LocalScale: {x: 1, y: 1, z: 1}
888+
m_ConstrainProportionsScale: 0
870889
m_Children: []
871890
m_Father: {fileID: 4427160273819458}
872891
m_RootOrder: 2
@@ -900,6 +919,7 @@ Transform:
900919
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
901920
m_LocalPosition: {x: 0, y: 0, z: 0}
902921
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
922+
m_ConstrainProportionsScale: 0
903923
m_Children: []
904924
m_Father: {fileID: 4427160273819458}
905925
m_RootOrder: 0
@@ -923,10 +943,12 @@ MeshRenderer:
923943
m_CastShadows: 1
924944
m_ReceiveShadows: 1
925945
m_DynamicOccludee: 1
946+
m_StaticShadowCaster: 0
926947
m_MotionVectors: 1
927948
m_LightProbeUsage: 1
928949
m_ReflectionProbeUsage: 1
929950
m_RayTracingMode: 2
951+
m_RayTraceProcedural: 0
930952
m_RenderingLayerMask: 1
931953
m_RendererPriority: 0
932954
m_Materials:
@@ -951,6 +973,7 @@ MeshRenderer:
951973
m_SortingLayerID: 0
952974
m_SortingLayer: 0
953975
m_SortingOrder: 0
976+
m_AdditionalVertexStreams: {fileID: 0}
954977
--- !u!65 &2314441812177900445
955978
BoxCollider:
956979
m_ObjectHideFlags: 0
@@ -991,6 +1014,7 @@ Transform:
9911014
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
9921015
m_LocalPosition: {x: 0, y: 0, z: 0}
9931016
m_LocalScale: {x: 1, y: 1, z: 1}
1017+
m_ConstrainProportionsScale: 0
9941018
m_Children: []
9951019
m_Father: {fileID: 4414771795277364}
9961020
m_RootOrder: 5
@@ -1030,6 +1054,7 @@ Transform:
10301054
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
10311055
m_LocalPosition: {x: 0, y: 0, z: 0}
10321056
m_LocalScale: {x: 1, y: 1, z: 1}
1057+
m_ConstrainProportionsScale: 0
10331058
m_Children: []
10341059
m_Father: {fileID: 4414771795277364}
10351060
m_RootOrder: 4
@@ -1103,6 +1128,7 @@ Transform:
11031128
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
11041129
m_LocalPosition: {x: 0, y: 0, z: 0}
11051130
m_LocalScale: {x: 1, y: 1, z: 1}
1131+
m_ConstrainProportionsScale: 0
11061132
m_Children: []
11071133
m_Father: {fileID: 4446684710817404}
11081134
m_RootOrder: 2

Packages/webxr-interactions/Runtime/Scripts/ControllerInteraction.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public class ControllerInteraction : MonoBehaviour
3333
private Dictionary<int, Transform> handJoints = new Dictionary<int, Transform>();
3434
public GameObject inputProfileHandModelParent;
3535

36+
[Header("Input Bindings")]
37+
[SerializeField] private List<WebXRController.ButtonTypes> pickupButtons = new List<WebXRController.ButtonTypes> {
38+
WebXRController.ButtonTypes.Trigger,
39+
WebXRController.ButtonTypes.Grip,
40+
WebXRController.ButtonTypes.ButtonA
41+
};
42+
3643
private Vector3 currentVelocity;
3744
private Vector3 previousPos;
3845

@@ -76,6 +83,8 @@ private void Awake()
7683
#endif
7784
SetControllerVisible(false);
7885
SetHandJointsVisible(false);
86+
87+
7988
}
8089

8190
private void OnEnable()
@@ -113,17 +122,17 @@ private void Update()
113122
float normalizedTime = controller.GetButton(WebXRController.ButtonTypes.ButtonA) ? 1 :
114123
Mathf.Max(controller.GetAxis(WebXRController.AxisTypes.Trigger),
115124
controller.GetAxis(WebXRController.AxisTypes.Grip));
116-
117-
if (controller.GetButtonDown(WebXRController.ButtonTypes.Trigger)
118-
|| controller.GetButtonDown(WebXRController.ButtonTypes.Grip)
119-
|| controller.GetButtonDown(WebXRController.ButtonTypes.ButtonA))
125+
126+
bool pickup = false;
127+
pickupButtons.ForEach(button => pickup = pickup || controller.GetButtonDown(button));
128+
if (pickup)
120129
{
121130
Pickup();
122131
}
123132

124-
if (controller.GetButtonUp(WebXRController.ButtonTypes.Trigger)
125-
|| controller.GetButtonUp(WebXRController.ButtonTypes.Grip)
126-
|| controller.GetButtonUp(WebXRController.ButtonTypes.ButtonA))
133+
bool drop = false;
134+
pickupButtons.ForEach(button => drop = drop || controller.GetButtonUp(button));
135+
if (drop)
127136
{
128137
Drop();
129138
}

0 commit comments

Comments
 (0)