- Home /
Advanced Unity: Custom touch input origin
Hi guys,
In Short: I want to use touch events on a world canvas independent of the viewing camera.
More Details:
- On a Table in the virtual room lies a virtual tablet (WorldSpace Canvas).
- The user can control it through a real tablet. (Kind of working)
- The touch inputs are sent from a tablet to the desktop-pc and piped into the unity input system via a custom touch input module which then controls Unity UI. This works fine.
- Also the touch visualization of the touches on the canvas ( works fine).
The main problem is, that the touches are mapped to the canvas using the main camera as reference system => If the button is being rendered in the corner, I also have to touch in the corner, even if it actually is in the middle of the canvas.
How can I map the touch coordinates directly to the canvas, independent of the camera?
I already tried adding a second camera tracked at the canvas, it works, but as soon as I build my project, the second camera seems to be ignored, wich results, once again, in wrong touch mappings.
Thanks for your help! I am very curious about your solutions and ideas :)
Answer by allesisda · Jan 08, 2018 at 02:51 PM
Solution: You can assign a camera to the canvas via canvas.worldcamera. The camera doesnt need to render anything. But it should have its target display set to Display 1.
Your answer
![](https://koobas.hobune.stream/wayback/20220612150050im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Exporting to Touch Screen Monitors or Touch Screen Displays 0 Answers
How to prevent touch passing through UI ? 0 Answers
EventSystem not detecting all UI elements 1 Answer
UI button and Touch Input conflict 1 Answer
Problem with touch and ui button 5 Answers