@@ -29,10 +29,7 @@ namespace Google.XR.Extensions.Samples.XRController
2929 /// </summary>
3030 public class XRControllerDisplay : MonoBehaviour
3131 {
32- private readonly List < ( InputAction action ,
33- Action < InputAction . CallbackContext > onStarted ,
34- Action < InputAction . CallbackContext > onPerformed ,
35- Action < InputAction . CallbackContext > onCanceled ) > _bindings = new ( ) ;
32+ private readonly List < BindingInfo > _bindings = new List < BindingInfo > ( ) ;
3633
3734#pragma warning disable CS0649 // Serialized fields don't need assignment.
3835 [ Header ( "Buttons" ) ]
@@ -90,26 +87,26 @@ private void OnEnable()
9087
9188 private void OnDisable ( )
9289 {
93- foreach ( var ( action , onStarted , onPerformed , onCanceled ) in _bindings )
90+ foreach ( var binding in _bindings )
9491 {
95- if ( action == null )
92+ if ( binding . Action == null )
9693 {
9794 continue ;
9895 }
9996
100- if ( onStarted != null )
97+ if ( binding . OnStarted != null )
10198 {
102- action . started -= onStarted ;
99+ binding . Action . started -= binding . OnStarted ;
103100 }
104101
105- if ( onPerformed != null )
102+ if ( binding . OnPerformed != null )
106103 {
107- action . performed -= onPerformed ;
104+ binding . Action . performed -= binding . OnPerformed ;
108105 }
109106
110- if ( onCanceled != null )
107+ if ( binding . OnCanceled != null )
111108 {
112- action . canceled -= onCanceled ;
109+ binding . Action . canceled -= binding . OnCanceled ;
113110 }
114111 }
115112
@@ -140,7 +137,8 @@ private void BindPress(InputAction action, XrControllerButtonInfo target)
140137 action . started += started ;
141138 action . canceled += canceled ;
142139
143- _bindings . Add ( ( action , started , null , canceled ) ) ;
140+ _bindings . Add (
141+ new BindingInfo { Action = action , OnStarted = started , OnCanceled = canceled } ) ;
144142 }
145143
146144 private void BindAxis ( InputAction action , XrControllerButtonInfo target )
@@ -157,7 +155,12 @@ private void BindAxis(InputAction action, XrControllerButtonInfo target)
157155 action . performed += performed ;
158156 action . canceled += canceled ;
159157
160- _bindings . Add ( ( action , null , performed , canceled ) ) ;
158+ _bindings . Add ( new BindingInfo
159+ {
160+ Action = action ,
161+ OnPerformed = performed ,
162+ OnCanceled = canceled
163+ } ) ;
161164 }
162165
163166 private void BindThumbstickVector2 ( InputAction action , Transform stickTransform )
@@ -191,7 +194,12 @@ private void BindThumbstickVector2(InputAction action, Transform stickTransform)
191194 action . performed += performed ;
192195 action . canceled += canceled ;
193196
194- _bindings . Add ( ( action , null , performed , canceled ) ) ;
197+ _bindings . Add ( new BindingInfo
198+ {
199+ Action = action ,
200+ OnPerformed = performed ,
201+ OnCanceled = canceled
202+ } ) ;
195203 }
196204
197205 private void EnableActions ( params InputAction [ ] actions )
@@ -224,6 +232,14 @@ private void ResetAll()
224232 _thumbstickTransform . localRotation = _thumbstickInitialRotation ;
225233 }
226234 }
235+
236+ private struct BindingInfo
237+ {
238+ public InputAction Action ;
239+ public Action < InputAction . CallbackContext > OnStarted ;
240+ public Action < InputAction . CallbackContext > OnPerformed ;
241+ public Action < InputAction . CallbackContext > OnCanceled ;
242+ }
227243 }
228244
229245 /// <summary>
0 commit comments