i have an major problem in my App. I have developed a crossplatform application with the native unity ui. Till now everything is working fine. But now i want to limit the touchcount on the UI to 1 so that it is impossible to click 2 Buttons at the same time. First thought was to set the Input.multitouchEnabled = false, which indeed works. But sadly I need the multitouch outside the UI for scale gestures and the XR Interaction Toolkit.
Are there any ideas to limit the touchcount only in the UI to 1?
Would really need the help of u.
Success - I found a working solution for me.
Key was to edit the Standalone Input module. Even this is sure not the best solution - it works.
So for this u have to add following lines to the Standalone Input module:
private bool ProcessTouchEvents()
{
int touchCount = input.touchCount;
if(touchCount > 1)
{
for (int i = 0; i < touchCount; ++i)
{
if(EventSystem.current.IsPointerOverGameObject(i))
{
touchCount = 1;
break;
}
}
}
for (int i = 0; i < touchCount; ++i)
{
Touch touch = input.GetTouch(i);
.
.
.
.
This will limit the touches on the UI to 1 and outside the UI multitouch still works!!
EDIT:
To be clean - copy the Standard Input Module of your current Unity Version in to your Repository and edit the copied one and use that in your project.
Hey @d4n3x I was reading this and I couldn’t understand your solution. Can you clarify?
Sorry for bringing this post back to life…
You downloaded the Standard (standalone?) Input Module from a decompiled unity repo and changed the code?
How did you add that back into unity? Is it a separate package? Does that change any of the default Input class uses?