@@ -134,7 +134,19 @@ public UpdateType updateType
134
134
135
135
[ SerializeField ] private Handedness hand ;
136
136
137
- [ SerializeField ] private XRBaseController xrController ;
137
+ [ SerializeField ] private XRBaseController xrController ;
138
+
139
+ [ SerializeField ] private InputActionProperty positionActionProperty ;
140
+ [ SerializeField ] private InputActionProperty rotationActionProperty ;
141
+ [ SerializeField ] private InputActionProperty trackingStateActionProperty ;
142
+ [ SerializeField ] private InputActionProperty triggerActionProperty ;
143
+ [ SerializeField ] private InputActionProperty gripActionProperty ;
144
+ [ SerializeField ] private InputActionProperty touchpadActionProperty ;
145
+ [ SerializeField ] private InputActionProperty touchpadPressedActionProperty ;
146
+ [ SerializeField ] private InputActionProperty thumbstickActionProperty ;
147
+ [ SerializeField ] private InputActionProperty thumbstickPressedActionProperty ;
148
+ [ SerializeField ] private InputActionProperty buttonAActionProperty ;
149
+ [ SerializeField ] private InputActionProperty buttonBActionProperty ;
138
150
139
151
#if WEBXR_INPUT_PROFILES
140
152
private InputProfileLoader inputProfileLoader ;
@@ -145,7 +157,6 @@ public UpdateType updateType
145
157
private string loadedProfile = null ;
146
158
private bool loadedModel = false ;
147
159
private static Quaternion quat180 = Quaternion . Euler ( 0 , 180 , 0 ) ;
148
- private WebXRInputActions actions = null ;
149
160
private InputAction positionAction ;
150
161
private InputAction rotationAction ;
151
162
private InputAction trackingStateAction ;
@@ -184,15 +195,7 @@ void BindPosition()
184
195
if ( m_PositionBound )
185
196
return ;
186
197
187
- switch ( hand )
188
- {
189
- case Handedness . Left :
190
- positionAction = actions . XRLeftHand . Position ;
191
- break ;
192
- case Handedness . Right :
193
- positionAction = actions . XRRightHand . Position ;
194
- break ;
195
- }
198
+ positionAction = positionActionProperty . action ;
196
199
if ( positionAction == null )
197
200
return ;
198
201
@@ -206,15 +209,7 @@ void BindRotation()
206
209
if ( m_RotationBound )
207
210
return ;
208
211
209
- switch ( hand )
210
- {
211
- case Handedness . Left :
212
- rotationAction = actions . XRLeftHand . Rotation ;
213
- break ;
214
- case Handedness . Right :
215
- rotationAction = actions . XRRightHand . Rotation ;
216
- break ;
217
- }
212
+ rotationAction = rotationActionProperty . action ;
218
213
if ( rotationAction == null )
219
214
return ;
220
215
@@ -228,15 +223,7 @@ void BindTrackingState()
228
223
if ( m_TrackingStateBound )
229
224
return ;
230
225
231
- switch ( hand )
232
- {
233
- case Handedness . Left :
234
- trackingStateAction = actions . XRLeftHand . TrackingState ;
235
- break ;
236
- case Handedness . Right :
237
- trackingStateAction = actions . XRRightHand . TrackingState ;
238
- break ;
239
- }
226
+ trackingStateAction = trackingStateActionProperty . action ;
240
227
if ( trackingStateAction == null )
241
228
return ;
242
229
@@ -252,29 +239,14 @@ void InitVisualActions()
252
239
253
240
buttonActions = new InputAction [ 6 ] ;
254
241
axisActions = new InputAction [ 2 ] ;
255
- switch ( hand )
256
- {
257
- case Handedness . Left :
258
- buttonActions [ 0 ] = actions . XRLeftHand . Trigger ;
259
- buttonActions [ 1 ] = actions . XRLeftHand . Grip ;
260
- buttonActions [ 2 ] = actions . XRLeftHand . TouchpadPressed ;
261
- buttonActions [ 3 ] = actions . XRLeftHand . ThumbstickPressed ;
262
- buttonActions [ 4 ] = actions . XRLeftHand . ButtonA ;
263
- buttonActions [ 5 ] = actions . XRLeftHand . ButtonB ;
264
- axisActions [ 0 ] = actions . XRLeftHand . Touchpad ;
265
- axisActions [ 1 ] = actions . XRLeftHand . Thumbstick ;
266
- break ;
267
- case Handedness . Right :
268
- buttonActions [ 0 ] = actions . XRRightHand . Trigger ;
269
- buttonActions [ 1 ] = actions . XRRightHand . Grip ;
270
- buttonActions [ 2 ] = actions . XRRightHand . TouchpadPressed ;
271
- buttonActions [ 3 ] = actions . XRRightHand . ThumbstickPressed ;
272
- buttonActions [ 4 ] = actions . XRRightHand . ButtonA ;
273
- buttonActions [ 5 ] = actions . XRRightHand . ButtonB ;
274
- axisActions [ 0 ] = actions . XRRightHand . Touchpad ;
275
- axisActions [ 1 ] = actions . XRRightHand . Thumbstick ;
276
- break ;
277
- }
242
+ buttonActions [ 0 ] = triggerActionProperty . action ;
243
+ buttonActions [ 1 ] = gripActionProperty . action ;
244
+ buttonActions [ 2 ] = touchpadPressedActionProperty . action ;
245
+ buttonActions [ 3 ] = thumbstickPressedActionProperty . action ;
246
+ buttonActions [ 4 ] = buttonAActionProperty . action ;
247
+ buttonActions [ 5 ] = buttonBActionProperty . action ;
248
+ axisActions [ 0 ] = touchpadActionProperty . action ;
249
+ axisActions [ 1 ] = thumbstickActionProperty . action ;
278
250
279
251
visualActionsInit = true ;
280
252
}
@@ -358,7 +330,6 @@ void OnTrackingStateCanceled(InputAction.CallbackContext context)
358
330
359
331
private void Awake ( )
360
332
{
361
- actions = new WebXRInputActions ( ) ;
362
333
inputProfileLoader = rigOrigin . GetComponent < InputProfileLoader > ( ) ;
363
334
if ( inputProfileLoader == null )
364
335
{
@@ -381,7 +352,6 @@ private void Awake()
381
352
/// </summary>
382
353
protected void OnEnable ( )
383
354
{
384
- actions . Enable ( ) ;
385
355
BindActions ( ) ;
386
356
InputSystem . onAfterUpdate += UpdateCallback ;
387
357
@@ -405,7 +375,6 @@ protected void OnEnable()
405
375
/// </summary>
406
376
protected void OnDisable ( )
407
377
{
408
- actions . Disable ( ) ;
409
378
UnbindActions ( ) ;
410
379
InputSystem . onAfterUpdate -= UpdateCallback ;
411
380
switch ( hand )
0 commit comments