@@ -71,11 +71,22 @@ public enum Axis2DTypes
71
71
private InputDeviceCharacteristics xrHand = InputDeviceCharacteristics . Controller ;
72
72
private InputDevice ? inputDevice ;
73
73
private HapticCapabilities ? hapticCapabilities ;
74
+ private int buttonsFrameUpdate = - 1 ;
75
+
76
+ private void Update ( )
77
+ {
78
+ TryUpdateButtons ( ) ;
79
+ }
74
80
#endif
75
81
76
- public void TryUpdateButtons ( )
82
+ private void TryUpdateButtons ( )
77
83
{
78
84
#if UNITY_EDITOR
85
+ if ( buttonsFrameUpdate == Time . frameCount )
86
+ {
87
+ return ;
88
+ }
89
+ buttonsFrameUpdate = Time . frameCount ;
79
90
if ( ! WebXRManager . Instance . isSubsystemAvailable && inputDevice != null )
80
91
{
81
92
inputDevice . Value . TryGetFeatureValue ( CommonUsages . trigger , out trigger ) ;
@@ -151,6 +162,7 @@ private void UpdateButtons(WebXRControllerButton[] buttons)
151
162
152
163
public float GetAxis ( AxisTypes action )
153
164
{
165
+ TryUpdateButtons ( ) ;
154
166
switch ( action )
155
167
{
156
168
case AxisTypes . Grip :
@@ -163,6 +175,7 @@ public float GetAxis(AxisTypes action)
163
175
164
176
public Vector2 GetAxis2D ( Axis2DTypes action )
165
177
{
178
+ TryUpdateButtons ( ) ;
166
179
switch ( action )
167
180
{
168
181
case Axis2DTypes . Thumbstick :
@@ -175,6 +188,7 @@ public Vector2 GetAxis2D(Axis2DTypes action)
175
188
176
189
public bool GetButton ( ButtonTypes action )
177
190
{
191
+ TryUpdateButtons ( ) ;
178
192
if ( ! buttonStates . ContainsKey ( action ) )
179
193
{
180
194
return false ;
@@ -209,6 +223,7 @@ private void SetPastButtonState(ButtonTypes action, bool isPressed)
209
223
210
224
public bool GetButtonDown ( ButtonTypes action )
211
225
{
226
+ TryUpdateButtons ( ) ;
212
227
if ( GetButton ( action ) && ! GetPastButtonState ( action ) )
213
228
{
214
229
SetPastButtonState ( action , true ) ;
@@ -219,6 +234,7 @@ public bool GetButtonDown(ButtonTypes action)
219
234
220
235
public bool GetButtonUp ( ButtonTypes action )
221
236
{
237
+ TryUpdateButtons ( ) ;
222
238
if ( ! GetButton ( action ) && GetPastButtonState ( action ) )
223
239
{
224
240
SetPastButtonState ( action , false ) ;
@@ -229,6 +245,7 @@ public bool GetButtonUp(ButtonTypes action)
229
245
230
246
public float GetButtonIndexValue ( int index )
231
247
{
248
+ TryUpdateButtons ( ) ;
232
249
switch ( index )
233
250
{
234
251
case 0 :
@@ -249,6 +266,7 @@ public float GetButtonIndexValue(int index)
249
266
250
267
public float GetAxisIndexValue ( int index )
251
268
{
269
+ TryUpdateButtons ( ) ;
252
270
switch ( index )
253
271
{
254
272
case 0 :
0 commit comments