arfoundation-samples icon indicating copy to clipboard operation
arfoundation-samples copied to clipboard

"Interaction" scene and AR simulation

Open AlexandreSoteras opened this issue 3 years ago • 29 comments

Hi,

I'm trying to find a workflow using AR Foundation and the XR Interaction Toolkit.

If if try the scene "Interaction" on the XR Simulation scene, it's not working : clicking with a mouse on a detected surface doesn't do anything. It's working fine when it's build on Android.

Is this a known limitation or am I doing something wrong ? The scene "SimpleAR" is working fine on the XR Simulation Scene.

Thanks!

AlexandreSoteras avatar Jan 24 '23 15:01 AlexandreSoteras

Likewise, the XR simulation feels pretty useless for previewing placing a product in situ and interacting with the scene through XR Interaction Toolkit, any fixes or ideas?

ROBYER1 avatar Jan 26 '23 13:01 ROBYER1

I asked the same in the Unity forum last week. no reply yet. Dilmer Valecillos confirms that he couldn't make XRI and AR Simulation work together, too. let's cross fingers that some Unity dev will improve these

StefanoCecere avatar Feb 07 '23 21:02 StefanoCecere

Hi folks, apologies for radio silence on this issue.

The XR Interaction Toolkit team has begun working on updates to their AR components to be compatible with XR Simulation. We'll update this thread once they have more to share about that.

The issue is that the XR Interaction Toolkit components currently use the Input System's touchscreen bindings, so you would have to provide touchscreen input to Unity for these components to work in Simulation. In the AR Foundation samples we use Pointer bindings for everything. Pointer resolves to a touch input on mobile and a mouse input on desktop, allowing us to write a common set of code that executes in Simulation as well as iOS and Android platforms.

For anyone writing their own input scripts, you could look at our PressInputBase class for inspiration on how to implement simulation-agnostic input.

andyb-unity avatar May 22 '23 21:05 andyb-unity

Did anyone get it working for the time being?

apurvvarshney avatar Jun 05 '23 23:06 apurvvarshney

I hope you'll all find this helpful. I've created a GitHub template repo (which means you can quickly create your own repo from it) that uses AR Foundation and XRI together, with a demo scene using XR Simulation to place and manipulate AR objects.

This short video shows how it works: https://www.loom.com/share/35e79df3781a4b9992e516e6c8cb5a7c

The repo is here and I've tried to make the README pretty clear about how to get started: https://github.com/JasonSpatial/ar-template

I hope this helps.

jasononaquest avatar Jun 06 '23 00:06 jasononaquest

Thanks @JasonSpatial!

I saw Jason give a talk at the GameDevGuild conference a couple weeks ago where I learned of his workaround. He uses the Input System's TouchSimulation while working with XRI in the Editor (does not support multi-touch input): https://github.com/JasonSpatial/ar-template/blob/main/Assets/_Project/Scripts/Editor/ToolsEditor.cs

In this case he enables and disables touch simulation via a button on a component Inspector. This might be a suitable workaround for some folks in the meantime until XRI supports AR Foundation's XR Simulation.

andyb-unity avatar Jun 06 '23 01:06 andyb-unity

I hope you'll all find this helpful. I've created a GitHub template repo (which means you can quickly create your own repo from it) that uses AR Foundation and XRI together, with a demo scene using XR Simulation to place and manipulate AR objects.

This short video shows how it works: https://www.loom.com/share/35e79df3781a4b9992e516e6c8cb5a7c

The repo is here and I've tried to make the README pretty clear about how to get started: https://github.com/JasonSpatial/ar-template

I hope this helps.

great! no way it works with 2022.3?

StefanoCecere avatar Jun 06 '23 05:06 StefanoCecere

I think it should work with 2022.3. The repo is on 2023 but AR Foundation and XRI are doing all the work so you could whip up a new project pretty quickly.

On Mon, Jun 5, 2023 at 11:01 PM Stefano Cecere @.***> wrote:

I hope you'll all find this helpful. I've created a GitHub template repo (which means you can quickly create your own repo from it) that uses AR Foundation and XRI together, with a demo scene using XR Simulation to place and manipulate AR objects.

This short video shows how it works: https://www.loom.com/share/35e79df3781a4b9992e516e6c8cb5a7c

The repo is here and I've tried to make the README pretty clear about how to get started: https://github.com/JasonSpatial/ar-template

I hope this helps.

great! no way it works with 2022.3?

jasononaquest avatar Jun 06 '23 05:06 jasononaquest

Hi all, we've learned that XR Interaction Toolkit (XRI) 2.5 will include some mobile AR refactors, one of which is adding support for AR Foundation's XR Simulation. XRI 2.5 is not public yet but I thought followers of this thread would like to know this is coming.

andyb-unity avatar Jul 25 '23 05:07 andyb-unity

Hi all, we've learned that XR Interaction Toolkit (XRI) 2.5 will include some mobile AR refactors, one of which is adding support for AR Foundation's XR Simulation. XRI 2.5 is not public yet but I thought followers of this thread would like to know this is coming.

Thanks for the information ! Any ETA for XRI 2.5 ?

AlexandreSoteras avatar Jul 25 '23 11:07 AlexandreSoteras

Thank you big time for this solution Jason, going to give it a try. I was also curious if there was a clear timeline for XRI 2.5? Trying to help my students tinker with AR Foundation, and it would be great to have something to go to as a backup for testing!

profkeegan avatar Aug 30 '23 13:08 profkeegan

Hi all, happy to share that XRI 2.5 is out now! Looks like the docs haven't uploaded yet (this usually takes up to 48 hours after release), but I see 2.5.0 in the public registry, so you should be able to manually request this version in Package Manager.

andyb-unity avatar Aug 30 '23 17:08 andyb-unity

i see it in the docs https://docs.unity3d.com/Packages/[email protected]/manual/index.html but not in the public registry (still 2.4.3) :)

StefanoCecere avatar Aug 30 '23 17:08 StefanoCecere

The Package Manager in the Unity Editor does not show you the public registry-- it shows you a snapshot of the public registry at the time that the Editor was released. If you add the package by name and specify version 2.5.0, you'll see that the package is in fact in the public registry. https://docs.unity3d.com/Manual/upm-ui-quick.html

andyb-unity avatar Aug 30 '23 18:08 andyb-unity

I updated to 2.5.0, but the mouse clicking is still not detected in the XR simulation against a detected floor, am I doing something wrong ? I'm using the "AR Placement Interactable" component.

It's working fine on the starter scene "ARDemoScene" but this scene doesn't use this component

AlexandreSoteras avatar Aug 31 '23 12:08 AlexandreSoteras

The Package Manager in the Unity Editor does not show you the public registry-- it shows you a snapshot of the public registry at the time that the Editor was released. If you add the package by name and specify version 2.5.0, you'll see that the package is in fact in the public registry. https://docs.unity3d.com/Manual/upm-ui-quick.html

done modifying the packages manifest file, thank you!

StefanoCecere avatar Aug 31 '23 12:08 StefanoCecere

I didn't get the impression that 2.5 would take away the need to simulate touch. In fact, looking at the XR Screen Space Controller, it has input mappings for Touchscreen Gestures, which suggests it's still expecting a simulated touchscreen gesture.

This still works the way it worked before, by enabling Touch Simulation, either via the Input Debugger or via script, as I've done here with a simple editor script for an empty component I've added to AR Session.

image

jasononaquest avatar Aug 31 '23 14:08 jasononaquest

I haven't tried this yet myself but it looks like you can set up Editor input by modifying the Touchscreen Gestures Input Action Map as shown on this new page in their docs: https://docs.unity3d.com/Packages/[email protected]/manual/ar-interaction-overview.html

andyb-unity avatar Aug 31 '23 15:08 andyb-unity

Apologies if this is a Unity forum question as I am more on the art/design end of things. I've tested your amazing project @JasonSpatial but am curious how I would be able to integrate this script into the AR Sample project provided by [Unity] (https://github.com/Unity-Technologies/arfoundation-samples). I would very much love to leverage both the interactable functionality with image tracking but feel like I am running into the same testing roadblocks. I've tried to setup the inputs as mentioned in 2.5 with no luck.

I also neglected to mention I am working on a 2022.3.0f1 version if that would present another complication.

profkeegan avatar Aug 31 '23 17:08 profkeegan

@Creepymulder ARPlacementInteractable is part of the old way of setting up a scene for AR. Here is a doc page for how to set up AR with the new changes in XRI 2.5.

@profkeegan Just to be sure, include the Input Action Map provided by the XRI 2.5 Starter Assets referenced by your InputActionManager in the scene. Without it gestures will not be detected. If you want a working example please take a look at the AR Stater Asset's ARDemoScene. You can pull these starter assets by checking out the XRI package from the package manager window.

Also, only one-finger touch gestures are currently supported in simulation mode.

tropicdragon avatar Aug 31 '23 18:08 tropicdragon