New UI: disable multitouch
Asked Answered
S

4

0

Hi, everyone! I am wondering if it is good to disable multitouch with new UI with this Input.multiTouchEnabled?
Could you please advice me, where it is better to execute this code?

Also, I am curious if there is a more advanced method of handling touches within new Touch input module or Eventsystem?

Spread answered 9/2 at 18:45 Comment(0)
H
0

Hi,

We had a similar doubt when implementing our UI with the new Unity UI. Our UI was getting messy when more than one UI button was pressed simultaneously and we wanted to disable that and allow only one input touch.

So we set the “Input.multiTouchEnabled” to false in our first scene manager’s Awake() and it worked fine. Only one UI element was taking input/touch after that. Although, in the Unity editor Input.multiTouchEnabled was still showing as true even after setting to false but when built onto a device, it worked without any issues. We haven’t checked with Unity remote.

Even in our gameplay we don’t need multitouch, so I guess its fine.

We searched in Unity docs but couldn’t find any other way or better way to disable multi touch with the new Input Modules or EventSystem.

Hope it helps. Cheers.

Homosexual answered 6/6, 2023 at 2:30 Comment(2)

Great answer! Thanks :)

Hut

Could you please show me a little part of your code? I'm working on this since 2 days... Please help..

Boast
T
0

I gave this a try and it stopped all the buttons working in the canvas - seems like a Unity bug here.

Tevis answered 2/9, 2018 at 13:20 Comment(0)
A
0
void Awake()
{
    Input.multiTouchEnabled = false;
}

this might not work on Editor using remote.
Try building the game.

Ase answered 9/2 at 18:45 Comment(0)
Y
0

I tried everything - disabling the multi touch, editing the input system and input manager assets, nothing helped, what I did was rather simple; in all methods that could cause a problem if called simultaneously I put this check:

if (Input.touchCount > 1) return; //do nothing
else //execute your code
{

}

Please, note that this might not work if you disable the multi touch in your awake/start, it works only if you keep the multi touch enabled.

Yaw answered 9/2 at 18:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.