I am building an AR iOS app that uses ARToolkit for Unity3D. My goal is to create a UI in World Space mode so that when I point the phone camera to an image, it will show the UI in 3D (e.g. select products or scroll through information list, etc...).
Instructions I followed:
https://github.com/artoolkit/ar6unity-wiki/wiki/Setting-Up-Your-First-ARToolKit-for-Unity-Scene
https://github.com/artoolkit/ar6unity-wiki/wiki/ARToolKit-for-Unity-on-iOS
I have no problem making UI Render Mode = Screen Space Overlay. That means the UI canvas is "fixed" on the screen regardless of camera movement. However, when I use World Space, the UI touch input events just don't trigger. Here is the setting for my project:
Marker2 is where the image detection happens. Then it should show 2 cubes and 1 UI canvas with button and scroll view (outside of this screenshot - don't matter regarding this)
This is my canvas properties. Note that I put it in Default layer so the UI will show and Render Mode = World Space:
OK, I held up my image and it detects and shows 2 cubes and the button. But any click or touch on the button has no effect. Previously in UI Layer and Screen Space Overlay, I can hit the button and it works fine (basically output some text in Console - doesn't matter).
Anyways I tried to test with a new project where I don't use ARToolkit but just a regular Camera. Everything works fine. So it definitely has something to do with ARToolkit interrupting the mobile touch events.
Please help and point me some direction on why mobile touch input doesn't work in ARToolkit using UI World Space.
This is really some trick stuff in unity.
You have to understand the following:
If you change the Canvas to World Space, Canvas will look for a camera with the tag "MainCamera" and use it as the camera to perform the raycast.
If the Camera with the "MainCamera" tag is not found, Unity will use the Camera that set in the Canvas' Event Camera slot.
So you either have to change the Camera's tag to "MainCamera" or plug the main camera to the Event Camera slot in the Canvas or perform both actions if his is not working with the artoolkit. From the screenshot you posted, that slot is not assigned because it says "None".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With