google-ar / arcore-unity-sdk

ARCore SDK for Unity
https://developers.google.com/ar
Other
1.4k stars 400 forks source link

The raycast go through the Canvas. #322

Closed robrtoprz closed 6 years ago

robrtoprz commented 6 years ago

Hi everyone, I have a Canvas in my scene and If I touch any button, the raycast go through the button and instantiate an object, how can I prevent that? I'm using the HelloARController. Thanks.

robrtoprz commented 6 years ago

I found a solution: add this line: if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId)) before the line: if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit)) It worked for me.

MustaphaGH commented 6 years ago

Hello , the Frame.Raycast method is used only to detect the Trackables objects of ARCore , it's not used for normal 3D Objects and Canvas. Take a look at the classical method of unity : Physics.Raycast

pablisho commented 6 years ago

Hi, thanks for the report and the workaround.

chaosemer commented 6 years ago

Glad you figured this out.

I'm closing this report as the issues you are describing are general Unity issues and not ARCore specific.