Search code examples
unity-game-engineaugmented-realityarcorear-foundationxri

XR Interaction Toolkit – Events are not thrown


I am developing a mobile ar application for android with Unity and AR Foundation. My current task is to implement the features scaling, rotating and dragging for 3d objects in the scene. While doing research I came across XRI in Unity. So I installed it and added the interactable components to my object, like ARSelectionInteractable, ARTranslationInteractable, ARRotationInteractable and ARScaleInteractable.

Those are visually working fine. In my case I need a feedback after I finish scaling, so I looked up and saw that there are many Interactable Events I can use. I subscribed to all events, although I only need the SelectExit(SelectExitEventArgs args), just to check if my implementation works and realized that none of them are triggered and I don’t know why. I looked in the documentation up if my project is correctly setup.

What I did by reading the documentation was:

  • reacreated the XR Origin
  • added an XRScreenSpaceController, XRRayInteractor and XRInteractionGroup (but I'm not sure if I really need them)
  • added ARGestureInteractor to the Main Camera
  • added XRInteractionManager
  • added XRUIInputModule next to EventSystem and removed old Input System UI Input Module
  • Switched from default DefaultInputAction from AR Foundation to default XRDefaultInputActions from XRI

I suspect that it is due to the setup of XRI. Maybe I’m missing something important regarding the EventSystem?

Hierarchy (with screenshots):

Version of Tools

  • ARFoundation, ARKit, ARCore 6.0.0.-pre.5
  • XR Interaction Toolkit 2.5.2
  • Unity 2023.2.6

To keep the post short, I'll only show a few lines of the subscription to the event:

public void SelectEnter(SelectEnterEventArgs args)
 => Debug.Log("SelectEnter");

public void SelectExit(SelectExitEventArgs args)
 => Debug.Log("SelectExit");

Solution

  • I fixed my issue by updating to the newest pre-version. I guess not using a rigidbody on the object that I manipulate might be the reason. Because before I didnt use it and I didnt want to use it, because in my understanding I dont need it if I dont use the physics engine. But in the newest XRI version the rigidbody is a must and cant be deleted. So maybe that was the reason.