diff --git a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/Visuals/SpatialManipulationReticle.cs b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/Visuals/SpatialManipulationReticle.cs index 305a71108..a68e7f4c8 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/Visuals/SpatialManipulationReticle.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/Visuals/SpatialManipulationReticle.cs @@ -2,6 +2,7 @@ // Licensed under the BSD 3-Clause using System; +using System.Collections.Generic; using UnityEngine; using UnityEngine.XR.Interaction.Toolkit; @@ -19,7 +20,6 @@ public class SpatialManipulationReticle : MonoBehaviour, IReticleVisual [field: SerializeField, Tooltip("The type of the reticle visuals. Scale or Rotate.")] public SpatialManipulationReticleType ReticleType { get; set; } - private Transform contextTransform; private Quaternion worldRotationCache; /// @@ -47,7 +47,23 @@ public void UpdateVisual(ReticleVisualUpdateArgs args) } else if (rayInteractor.interactablesHovered.Count > 0) { - RotateReticle(args.ReticleNormal, rayInteractor.interactablesHovered[0].transform); + int interactableIndex = 0; + + List hoveredInteractables = rayInteractor.interactablesHovered; + int hoveredCount = hoveredInteractables.Count; + if (hoveredCount > 1) + { + for (int i = 0; i < hoveredCount; i++) + { + if (hoveredInteractables[i] is BoundsHandleInteractable) + { + interactableIndex = i; + break; + } + } + } + + RotateReticle(args.ReticleNormal, hoveredInteractables[interactableIndex].transform); } } } diff --git a/org.mixedrealitytoolkit.spatialmanipulation/CHANGELOG.md b/org.mixedrealitytoolkit.spatialmanipulation/CHANGELOG.md index 9dca246f0..d25b24209 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/CHANGELOG.md +++ b/org.mixedrealitytoolkit.spatialmanipulation/CHANGELOG.md @@ -7,8 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Fixed * Fixed tap to place `StartPlacement()` when called just after instantiation of the component. [PR #785](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/785) +* Fix null ref in SpatialManipulationReticle when multiple interactables are hovered. [PR #873](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/873) -## [3.3.0-development] - 2024-04-30 +## [3.3.0] - 2024-04-30 ### Added @@ -18,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). * Added null check and index check when hiding colliders on BoundsHandleInteractable. [PR #730](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/730) -## [3.2.0-development] - 2024-03-20 +## [3.2.0] - 2024-03-20 ### Added