Skip to content

👨🏽‍💻Rolin

Developer

How to make Unity Flutter the touch working on Android

At this moment I’m developing a mobile application that needs AR functionality. For this AR functionality, I’m using Unity the AR Foundation. I used Inside Unity for the touch the old and new input systems.
If you don’t know which one you have, go to the Player Settings and then to Active Input Handling.

Active input handling

I had this on both and used the Enhanced touch system within Unity. This again uses the new active input handling, but is not yet supported on Android.

Here is the link to go the issue that describes this error: Unity's New Input system breaks touch input on android.

To solve this problem you can use the Input.Touches from Unity. In my example I need to get only the first touch and only the first one when it begins. To solve that I’ve used the following code:

if (Input.touchCount > 0 && Input.GetTouch(0).phase.Equals(TouchPhase.Began)) { // Call your function to handle what needs to be done on the touch. }

So if there is more then 0 touches get the first one and check if the phase equels the TouchPase.Began. When that’s true call the function to handle what needs to be done on touch.
There are more functions that you can use on the Input class. For more information about the Input class you can click here.