Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

XR Interaction Toolkit OnSelectExit is never called

Discussion in 'VR' started by BentelAnnR, Jun 30, 2020 at 9:12 AM.

  1. BentelAnnR

    BentelAnnR

    Joined:
    Jun 16, 2020
    Posts:
    3
    Hi all,

    I'm having some problems with the selection: while SelectEnter is correctly called by the InteractionManager, SelectExit is never called.

    I'm using the laser to select objects ("hover to select" field of XRRayInteractor set to true), the problem is: once an object is selected, I'm not able to select another object by interacting with it through the laser because the previous one keeps being in the selected state although it is no more hit by the laser.

    Debugging the application I've discovered that the SelectExit is never called by the InteractionManager, because the if statement of the following code is never passed, because interactor.selectTarget is set to null, for reasons I ignore, because interactor.selectTarget is correctly set in the selection phase.

    Code (CSharp):
    1.          void ClearInteractorSelection(XRBaseInteractor interactor)
    2.                  {
    3.                      // TODO: Make sure SelectExit is called if the selectTarget of the interactor is destroyed (and write a test around this).
    4.                      if (interactor.selectTarget &&
    5.                          (!interactor.isSelectActive || !interactor.CanSelect(interactor.selectTarget) || !interactor.selectTarget.IsSelectableBy(interactor)))
    6.                          SelectExit(interactor, interactor.selectTarget);
    7.                  }
    I'm quite sure I'm using the scripts the wrong way, so which is the correct way of enabling selection through the laser?

    Thanks in advance
     
unityunity