Making Canvas buttons 'modal' ie trapping touch events

Hi
Anyone doing ARkit development with Canvas buttons?
I haven’t been able to make them ‘modal’, ie trap touch events so they don’t get propagated to your actual 3D world.

Hi

Have you tried this:

https://docs.unity3d.com/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html

Might be something you can integrate to detect when you are touching the UI or not… and then prevent raycasting for the ARkit hit tests… I haven’t tried it with ARKit myself, but it did work for a non AR project I was playing around with.

Cheers
R

1 Like

Hi

Had another look at this today in the sample ARKit Balls scene… for anyone interested, my reply above didn’t work in the context of the touch being detected on the generated AR planes.

I ended up using the IPointerDownHandler interface in the event system.

https://docs.unity3d.com/ScriptReference/EventSystems.IPointerDownHandler.html

I added this to the plane prefab… so as planes are generated, they listen for the PointerDown event within their bounds… and events on UI Buttons don’t propagate to these planes.

Anyone got any better way, let us know
Cheers
R

At least for hit testing the first reply by richie-green above worked fine for me.

I know it’s been about a year since you looked into this - but do you remember exactly what you did? The first comment and the second comment reference different solutions but it seems like maybe you did both? I’ve been at this for 3 days now. Do I modify the ARKitHitTest script by adding the stuff from comment 1 and then hunt down the invisible plane prefab and just add the generic script?

Sorry for all the vague guesses but I’m really trying to figure this one out.

Hey @levilais

The first solution should work… Can you post your code where you are detecting clicks/touches and using the IsPointerOverGameObject.

Are you using ARInterface or the new ARFoundation?

Thanks