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,XRRayInteractorandXRInteractionGroup(but I'm not sure if I really need them) - added
ARGestureInteractorto theMain Camera - added
XRInteractionManager - added
XRUIInputModulenext toEventSystemand removed oldInput System UI Input Module - Switched from default
DefaultInputActionfrom AR Foundation to defaultXRDefaultInputActionsfrom XRI
I suspect that it is due to the setup of XRI. Maybe I’m missing something important regarding the EventSystem?
Hierarchy (with screenshots):
- ARSession-G
- ARSession
- ARInputManager
- XROrigin(AR)-G
- CameraOffset-G
- MainCamera-G
- ARGestureInteractor
- XRScreenSpaceController-G
- XRScreenSpaceController
- XRRayInteractor
- XRInteractionGroup
- MainCamera-G
- XROrigin
- InputActionManager
- ARPlaneManager
- ARRaycastManager
- ARAnchorManager
- CameraOffset-G
- XRInteractionManager-G
- XRInteractionManager
- EventSystem-G
- EventSystem
- XRUIInputModule
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");
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.