Skip to content

Commit 5dab273

Browse files
author
Unity Technologies
committed
## [2.5.4] - 2024-04-05 ### Fixed - Fixed compilation errors on tvOS platform where `ENABLE_VR` is not defined when AR Foundation is installed. Also fixed when XR Hands is installed in the Hands Interaction Demo sample. (Backport from 3.0.0) - Fixed `TrackedGraphicRaycaster` to clear poke interaction data when disabled. ([XRIT-142](https://issuetracker.unity3d.com/product/unity/issues/guid/XRIT-142)) (Backport from 3.0.0) - Fixed warning about use of deprecated `VersionsInfo.verified` by replacing with `VersionsInfo.recommended` in the Hands Interaction Demo sample in Unity 2022.2 and newer. (Backport from 3.0.0) - Fixed the XR Interactor Line Visual from bending towards an XR Interactable Snap Volume behind UI when the valid UI hit is closest. (Backport from 3.0.2) - Fixed tap gesture detection for selecting and spawning interactable objects in AR scenes. ([XRIT-145](https://issuetracker.unity3d.com/product/unity/issues/guid/XRIT-145)) (Backport from 3.0.2) - Changed the Tap Start Position input action to remove the Tap interaction from the `tapStartPosition` binding in the Starter Assets sample `XRI Default Input Actions` asset. The sample will need to be reimported to remove the Tap interaction from the binding for taps to be functional. This change along with changes to the `XRScreenSpaceController` also fixes the selected object from staying selected and movable with the mobile device orientation for 0.2 seconds after a tap was released.
1 parent 110bd64 commit 5dab273

17 files changed

+190
-85
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
<!-- Headers should be listed in this order: Added, Changed, Deprecated, Removed, Fixed, Security -->
88

9+
## [2.5.4] - 2024-04-05
10+
11+
### Fixed
12+
- Fixed compilation errors on tvOS platform where `ENABLE_VR` is not defined when AR Foundation is installed. Also fixed when XR Hands is installed in the Hands Interaction Demo sample. (Backport from 3.0.0)
13+
- Fixed `TrackedGraphicRaycaster` to clear poke interaction data when disabled. ([XRIT-142](https://issuetracker.unity3d.com/product/unity/issues/guid/XRIT-142)) (Backport from 3.0.0)
14+
- Fixed warning about use of deprecated `VersionsInfo.verified` by replacing with `VersionsInfo.recommended` in the Hands Interaction Demo sample in Unity 2022.2 and newer. (Backport from 3.0.0)
15+
- Fixed the XR Interactor Line Visual from bending towards an XR Interactable Snap Volume behind UI when the valid UI hit is closest. (Backport from 3.0.2)
16+
- Fixed tap gesture detection for selecting and spawning interactable objects in AR scenes. ([XRIT-145](https://issuetracker.unity3d.com/product/unity/issues/guid/XRIT-145)) (Backport from 3.0.2)
17+
- Changed the Tap Start Position input action to remove the Tap interaction from the `tapStartPosition` binding in the Starter Assets sample `XRI Default Input Actions` asset. The sample will need to be reimported to remove the Tap interaction from the binding for taps to be functional. This change along with changes to the `XRScreenSpaceController` also fixes the selected object from staying selected and movable with the mobile device orientation for 0.2 seconds after a tap was released.
18+
919
## [2.5.3] - 2024-02-28
1020

1121
### Fixed

Documentation~/includes/version.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.5.3
1+
2.5.4

Documentation~/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ To install this package (minimum version: 2.0.4), follow the [installation instr
1818
This package was not listed in the Editor manifest in earlier versions of Unity 2021. Due to this, installation is a manual process. To install this package:
1919
1. Open the project that you plan to use.
2020
1. Click the following link to bring up the **Add package by name** window in Package Manager:
21-
[com.unity.xr.interaction.toolkit](com.unity3d.kharma:upmpackage/[email protected].3)
21+
[com.unity.xr.interaction.toolkit](com.unity3d.kharma:upmpackage/[email protected].4)
2222

2323
![installation-add-package-by-name](images/installation-add-package-by-name.png)
2424

Documentation~/interactor-events.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ These are events that can be hooked into in the editor the same way you would re
44

55
| **Property** | **Description** |
66
|---|---|
7-
| **Hover Entered** | The event that is called when this Interactor begins hovering over an Interactable.<br />The `HoverEnterEventArgs` passed to each listener is only valid while the event is invoked, do not hold a reference to it. |
8-
| **Hover Exited** | The event that is called when this Interactor ends hovering over an Interactable.<br />The `HoverExitEventArgs` passed to each listener is only valid while the event is invoked, do not hold a reference to it. |
9-
| **Select Entered** | The event that is called when this Interactor begins selecting an Interactable.<br />The `SelectEnterEventArgs` passed to each listener is only valid while the event is invoked, do not hold a reference to it. |
10-
| **Select Exited** | The event that is called when this Interactor ends selecting an Interactable.<br />The `SelectEnterEventArgs` passed to each listener is only valid while the event is invoked, do not hold a reference to it. |
7+
| **Hover Entered** | The event that is called when this Interactor begins hovering over an Interactable.<br />The `HoverEnterEventArgs` passed to each listener is only valid while the event is invoked, don't hold a reference to it. |
8+
| **Hover Exited** | The event that is called when this Interactor ends hovering over an Interactable.<br />The `HoverExitEventArgs` passed to each listener is only valid while the event is invoked, don't hold a reference to it. |
9+
| **Select Entered** | The event that is called when this Interactor begins selecting an Interactable.<br />The `SelectEnterEventArgs` passed to each listener is only valid while the event is invoked, don't hold a reference to it. |
10+
| **Select Exited** | The event that is called when this Interactor ends selecting an Interactable.<br />The `SelectExitEventArgs` passed to each listener is only valid while the event is invoked, don't hold a reference to it. |

Runtime/AR/TouchscreenGestureInputController.cs

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#if AR_FOUNDATION_PRESENT || PACKAGE_DOCS_GENERATION
1+
// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled.
2+
// These are the guards that Input System uses in GenericXRDevice.cs to define the XRController and XRHMD classes.
3+
#if ((ENABLE_VR || UNITY_GAMECORE) && AR_FOUNDATION_PRESENT) || PACKAGE_DOCS_GENERATION
24
using System.Text;
35
using UnityEngine.InputSystem.Controls;
46
using UnityEngine.InputSystem.EnhancedTouch;
@@ -11,7 +13,7 @@ namespace UnityEngine.XR.Interaction.Toolkit.AR.Inputs
1113
/// <summary>
1214
/// An input device representing mobile 2D screen gestures.
1315
/// </summary>
14-
[InputControlLayout(stateType = typeof(TouchscreenGestureInputControllerState), displayName = "Touchscreen Gesture Input Controller", isGenericTypeOfDevice = true, updateBeforeRender = true)]
16+
[InputControlLayout(stateType = typeof(TouchscreenGestureInputControllerState), displayName = "Touchscreen Gesture Input Controller", isGenericTypeOfDevice = true, updateBeforeRender = false)]
1517
[Preserve]
1618
public class TouchscreenGestureInputController : InputSystem.XR.XRController, IInputUpdateCallbackReceiver
1719
{
@@ -168,22 +170,33 @@ public void OnUpdate()
168170
if (m_ControllerState.fingerCount != updatedTouchCount)
169171
{
170172
m_ControllerState.fingerCount = updatedTouchCount;
171-
InputState.Change(this, m_ControllerState);
173+
InputSystem.InputSystem.QueueStateEvent(this, m_ControllerState);
172174
}
173175
}
174176

175177
void OnGestureStarted<T>(Gesture<T> gesture) where T : Gesture<T>
176178
{
177179
gesture.onUpdated += OnGestureUpdated;
178180
gesture.onFinished += OnGestureFinished;
181+
182+
switch (gesture)
183+
{
184+
case TapGesture tapGesture:
185+
m_ControllerState.tapStartPosition = Vector2.zero;
186+
break;
187+
}
188+
189+
InputSystem.InputSystem.QueueStateEvent(this, m_ControllerState);
179190
}
180191

181192
void OnGestureUpdated<T>(Gesture<T> gesture) where T : Gesture<T>
182193
{
183194
switch (gesture)
184195
{
185196
case TapGesture tapGesture:
186-
m_ControllerState.tapStartPosition = tapGesture.startPosition;
197+
// Don't set the tapStartPosition since it should only be set when the gesture is successfully finished.
198+
// We don't have another control to indicate tap status, so we have to use the position control
199+
// for both status and position, so we must wait to set until the gesture is finished.
187200
break;
188201
case DragGesture dragGesture:
189202
m_ControllerState.dragStartPosition = dragGesture.startPosition;
@@ -209,15 +222,15 @@ void OnGestureUpdated<T>(Gesture<T> gesture) where T : Gesture<T>
209222
break;
210223
}
211224

212-
InputState.Change(this, m_ControllerState);
225+
InputSystem.InputSystem.QueueStateEvent(this, m_ControllerState);
213226
}
214227

215228
void OnGestureFinished<T>(Gesture<T> gesture) where T : Gesture<T>
216229
{
217230
switch (gesture)
218231
{
219-
case TapGesture tapGesture:
220-
m_ControllerState.tapStartPosition = Vector2.zero;
232+
case TapGesture tapGesture:
233+
m_ControllerState.tapStartPosition = !tapGesture.isCanceled ? tapGesture.startPosition : Vector2.zero;
221234
break;
222235
case DragGesture dragGesture:
223236
m_ControllerState.dragStartPosition = Vector2.zero;
@@ -243,7 +256,7 @@ void OnGestureFinished<T>(Gesture<T> gesture) where T : Gesture<T>
243256
break;
244257
}
245258

246-
InputState.Change(this, m_ControllerState);
259+
InputSystem.InputSystem.QueueStateEvent(this, m_ControllerState);
247260
}
248261

249262
/// <summary>

Runtime/AR/TouchscreenGestureInputLayoutLoader.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
#if AR_FOUNDATION_PRESENT || PACKAGE_DOCS_GENERATION
1+
// These are the guards in TouchscreenGestureInputController.cs
2+
#if ((ENABLE_VR || UNITY_GAMECORE) && AR_FOUNDATION_PRESENT) || PACKAGE_DOCS_GENERATION
3+
#define TOUCHSCREEN_GESTURE_INPUT_CONTROLLER_AVAILABLE
4+
#endif
5+
6+
#if TOUCHSCREEN_GESTURE_INPUT_CONTROLLER_AVAILABLE
27
using UnityEditor;
38
using UnityEngine.InputSystem.Layouts;
49
using UnityEngine.Scripting;

Runtime/Interaction/Controllers/XRScreenSpaceController.cs

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
// These are the guards in TouchscreenGestureInputController.cs
2+
#if ((ENABLE_VR || UNITY_GAMECORE) && AR_FOUNDATION_PRESENT) || PACKAGE_DOCS_GENERATION
3+
#define TOUCHSCREEN_GESTURE_INPUT_CONTROLLER_AVAILABLE
4+
#endif
5+
16
using UnityEngine.EventSystems;
27
using UnityEngine.InputSystem;
38
using UnityEngine.InputSystem.Controls;
49
using UnityEngine.Serialization;
510
using UnityEngine.XR.Interaction.Toolkit.Inputs;
611
using UnityEngine.XR.Interaction.Toolkit.UI;
712

8-
#if AR_FOUNDATION_PRESENT || PACKAGE_DOCS_GENERATION
13+
#if TOUCHSCREEN_GESTURE_INPUT_CONTROLLER_AVAILABLE
914
using UnityEngine.XR.Interaction.Toolkit.AR.Inputs;
1015
#endif
1116

@@ -191,7 +196,7 @@ public bool blockInteractionsWithScreenSpaceUI
191196
/// </remarks>
192197
public float scaleDelta { get; private set; }
193198

194-
#if AR_FOUNDATION_PRESENT
199+
#if TOUCHSCREEN_GESTURE_INPUT_CONTROLLER_AVAILABLE
195200
TouchscreenGestureInputController m_GestureInputController;
196201
#endif
197202
bool m_HasCheckedDisabledTrackingInputReferenceActions;
@@ -258,8 +263,7 @@ protected override void UpdateTrackingInput(XRControllerState controllerState)
258263
}
259264

260265
var currentTouchCount = m_ScreenTouchCountAction.action?.ReadValue<int>() ?? 0;
261-
controllerState.isTracked = currentTouchCount > 0;
262-
266+
263267
if (TryGetCurrentPositionAction(currentTouchCount, out var posAction))
264268
{
265269
var screenPos = posAction.ReadValue<Vector2>();
@@ -268,10 +272,12 @@ protected override void UpdateTrackingInput(XRControllerState controllerState)
268272
controllerState.position = transform.parent != null ? transform.parent.InverseTransformPoint(screenToWorldPoint) : screenToWorldPoint;
269273
controllerState.rotation = Quaternion.LookRotation(directionVector);
270274
controllerState.inputTrackingState = InputTrackingState.Position | InputTrackingState.Rotation;
275+
controllerState.isTracked = currentTouchCount > 0;
271276
}
272277
else
273278
{
274279
controllerState.inputTrackingState = InputTrackingState.None;
280+
controllerState.isTracked = false;
275281
}
276282
}
277283

@@ -304,11 +310,11 @@ protected override void UpdateInput(XRControllerState controllerState)
304310

305311
if (TryGetCurrentTwoInputSelectAction(out var twoInputSelectAction))
306312
{
307-
controllerState.selectInteractionState.SetFrameState(twoInputSelectAction.phase.IsInProgress(), twoInputSelectAction.ReadValue<float>());
313+
controllerState.selectInteractionState.SetFrameState(true, twoInputSelectAction.ReadValue<float>());
308314
}
309315
else if (TryGetCurrentOneInputSelectAction(out var oneInputSelectAction))
310316
{
311-
controllerState.selectInteractionState.SetFrameState(oneInputSelectAction.phase == InputActionPhase.Started, oneInputSelectAction.ReadValue<Vector2>().magnitude);
317+
controllerState.selectInteractionState.SetFrameState(true, oneInputSelectAction.ReadValue<Vector2>().magnitude);
312318
}
313319
else
314320
{
@@ -323,14 +329,14 @@ bool TryGetCurrentPositionAction(int touchCount, out InputAction action)
323329
if (touchCount <= 1)
324330
{
325331
if (m_DragCurrentPositionAction.action != null &&
326-
m_DragCurrentPositionAction.action.phase == InputActionPhase.Started)
332+
m_DragCurrentPositionAction.action.IsInProgress())
327333
{
328334
action = m_DragCurrentPositionAction.action;
329335
return true;
330336
}
331337

332338
if (m_TapStartPositionAction.action != null &&
333-
m_TapStartPositionAction.action.phase == InputActionPhase.Started)
339+
m_TapStartPositionAction.action.WasPerformedThisFrame())
334340
{
335341
action = m_TapStartPositionAction.action;
336342
return true;
@@ -344,14 +350,14 @@ bool TryGetCurrentPositionAction(int touchCount, out InputAction action)
344350
bool TryGetCurrentOneInputSelectAction(out InputAction action)
345351
{
346352
if (m_DragCurrentPositionAction.action != null &&
347-
m_DragCurrentPositionAction.action.phase == InputActionPhase.Started)
353+
m_DragCurrentPositionAction.action.IsInProgress())
348354
{
349355
action = m_DragCurrentPositionAction.action;
350356
return true;
351357
}
352358

353359
if (m_TapStartPositionAction.action != null &&
354-
m_TapStartPositionAction.action.phase == InputActionPhase.Started)
360+
m_TapStartPositionAction.action.WasPerformedThisFrame())
355361
{
356362
action = m_TapStartPositionAction.action;
357363
return true;
@@ -364,21 +370,21 @@ bool TryGetCurrentOneInputSelectAction(out InputAction action)
364370
bool TryGetCurrentTwoInputSelectAction(out InputAction action)
365371
{
366372
if (m_PinchGapAction.action != null &&
367-
m_PinchGapAction.action.phase.IsInProgress())
373+
m_PinchGapAction.action.IsInProgress())
368374
{
369375
action = m_PinchGapAction.action;
370376
return true;
371377
}
372378

373379
if (m_PinchGapDeltaAction.action != null &&
374-
m_PinchGapDeltaAction.action.phase.IsInProgress())
380+
m_PinchGapDeltaAction.action.IsInProgress())
375381
{
376382
action = m_PinchGapDeltaAction.action;
377383
return true;
378384
}
379385

380386
if (m_TwistDeltaRotationAction.action != null &&
381-
m_TwistDeltaRotationAction.action.phase.IsInProgress())
387+
m_TwistDeltaRotationAction.action.IsInProgress())
382388
{
383389
action = m_TwistDeltaRotationAction.action;
384390
return true;
@@ -419,7 +425,7 @@ bool IsPointerOverScreenSpaceCanvas()
419425

420426
void InitializeTouchscreenGestureController()
421427
{
422-
#if AR_FOUNDATION_PRESENT
428+
#if TOUCHSCREEN_GESTURE_INPUT_CONTROLLER_AVAILABLE
423429
if (!m_EnableTouchscreenGestureInputController)
424430
return;
425431

@@ -436,7 +442,7 @@ void InitializeTouchscreenGestureController()
436442

437443
void DestroyTouchscreenGestureController()
438444
{
439-
#if AR_FOUNDATION_PRESENT
445+
#if TOUCHSCREEN_GESTURE_INPUT_CONTROLLER_AVAILABLE
440446
if (m_GestureInputController != null && m_GestureInputController.added)
441447
{
442448
InputSystem.InputSystem.RemoveDevice(m_GestureInputController);

Runtime/Interaction/Interactors/Visual/XRInteractorLineVisual.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1038,11 +1038,14 @@ bool ExtractHitInformation(ref NativeArray<Vector3> targetPoints, int numTargetP
10381038
{
10391039
targetEndPoint = m_CurrentHitPoint;
10401040

1041-
if (validHit && m_SnapEndpointIfAvailable && m_HasRayInteractor)
1041+
// Since any UI hit is considered a valid hit, we need to skip snap volume logic if the UI hit is closer than the snap volume hit
1042+
if (validHit && m_SnapEndpointIfAvailable && m_HasRayInteractor &&
1043+
m_LineRenderableAsRayInteractor.TryGetCurrentRaycast(out var raycastHit, out _, out _, out _, out var isUIHitClosest) &&
1044+
!isUIHitClosest)
10421045
{
10431046
// When hovering a new collider, check if it has a specified snapping volume, if it does then get the closest point on it
1044-
if (m_LineRenderableAsRayInteractor.TryGetCurrent3DRaycastHit(out var raycastHit, out _))
1045-
hitCollider = raycastHit.collider;
1047+
if (raycastHit.HasValue)
1048+
hitCollider = raycastHit.Value.collider;
10461049

10471050
if (hitCollider != m_PreviousCollider && hitCollider != null)
10481051
m_LineRenderableAsBaseInteractor.interactionManager.TryGetInteractableForCollider(hitCollider, out _, out m_XRInteractableSnapVolume);
@@ -1053,7 +1056,7 @@ bool ExtractHitInformation(ref NativeArray<Vector3> targetPoints, int numTargetP
10531056
targetEndPoint = m_LineRenderableAsRayInteractor.hasSelection
10541057
? m_XRInteractableSnapVolume.GetClosestPointOfAttachTransform(m_LineRenderableAsRayInteractor)
10551058
: m_XRInteractableSnapVolume.GetClosestPoint(targetEndPoint);
1056-
1059+
10571060
m_EndPositionInLine = k_NumberOfSegmentsForBendableLine - 1; // Override hit index because we're going to use a custom line where the hit point is the end
10581061
hitSnapVolume = true;
10591062
}

Runtime/Interaction/Interactors/XRPokeInteractor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ public override void PreprocessInteractor(XRInteractionUpdateOrder.UpdatePhase u
251251

252252
if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
253253
{
254-
TrackedDeviceGraphicRaycaster.ValidatePokeInteractionData(this);
255254
isInteractingWithUI = TrackedDeviceGraphicRaycaster.IsPokeInteractingWithUI(this);
256255
RegisterValidTargets(out m_CurrentPokeTarget, out m_CurrentPokeFilter);
257256
ProcessPokeStateData();

0 commit comments

Comments
 (0)