Skip to content

Commit

Permalink
Fix issue with target not getting deselected
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-shariff committed Jan 9, 2024
1 parent 61f23c1 commit a9b3f64
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Runtime/Interaction/HPUIInteractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class HPUIInteractor: XRPokeInteractor, IHPUIInteractor
/// </summary>
public HPUISwipeEvent SwipeEvent { get => swipeEvent; set => swipeEvent = value; }


protected HPUIGestureLogic gestureLogic;
private List<IXRInteractable> validTargets = new List<IXRInteractable>();

/// <inheritdoc />
protected override void Awake()
Expand Down Expand Up @@ -86,20 +86,25 @@ public override void GetValidTargets(List<IXRInteractable> targets)
}

List<IXRInteractable> recievedTargets = ListPool<IXRInteractable>.Get();
recievedTargets.AddRange(targets);
recievedTargets.AddRange(targets.Distinct());

targets.Clear();
validTargets.Clear();
foreach(IXRInteractable target in recievedTargets.Select(t => t as IHPUIInteractable).Where(ht => ht != null).OrderBy(ht => ht.zOrder))
{
targets.Add(target);
validTargets.Add(target);
}

// TODO check if an interactable with lower z order is selected. If so cancel it.

ListPool<IXRInteractable>.Release(recievedTargets);
}

/// <inheritdoc />
public override bool CanSelect(IXRSelectInteractable interactable)
{
return ProcessSelectFilters(interactable);
return validTargets.Contains(interactable) && ProcessSelectFilters(interactable);
}


Expand Down

0 comments on commit a9b3f64

Please sign in to comment.