'Unity Build not taking touch input. Game works fine in Unity Remote
My android game is working fine in Unity Remote and all the touch controls are fine. But upon building, the game is not taking any input. The screen is not frozen, the sound and character animations are working fine. But no input is taken. It's not responding to any touch input even though it works fine in Remote. I've used the new input system and I've with both Input.GetTouch() and Input.touches().
void GetTouchInput()
{
for (int i = 0; i < Input.touchCount; i++)
{
//Touch t = Input.GetTouch(i);
Touch t = Input.touches[i];
switch (t.phase)
{
case TouchPhase.Began:
if (t.position.x < oneThirdScreenWidth && leftFingerID == -1 && middleFingerID == -1)
{
leftFingerID = t.fingerId;
moveTouchStartposition = t.position;
}
else if (t.position.x > 2 * oneThirdScreenWidth && rightFingerID == -1 && middleFingerID ==-1)
{
rightFingerID = t.fingerId;
}
else if (t.position.x > oneThirdScreenWidth && rightFingerID == -1 && leftFingerID ==-1)
{
middleFingerID = t.fingerId;
}
break;
case TouchPhase.Ended:
case TouchPhase.Canceled:
if (t.fingerId == leftFingerID)
{
leftFingerID = -1;
}
else if (t.fingerId == rightFingerID)
{
rightFingerID = -1;
}
else if (t.fingerId == middleFingerID)
{
middleFingerID = -1;
}
break;
case TouchPhase.Moved:
if (t.fingerId == rightFingerID)
{
lookInput = t.deltaPosition * cameraSensitivity * Time.deltaTime;
}
else if (t.fingerId == leftFingerID)
{
moveInput = t.position - moveTouchStartposition;
}
break;
case TouchPhase.Stationary:
if (t.fingerId == rightFingerID)
{
lookInput = Vector2.zero;
}
else if (t.fingerId == middleFingerID && Time.time >= timeToFire)
{
timeToFire = Time.time + 1 / fireRate;
fpsShooter.Shoot();
reticle.SetMaxSize();
}
break;
}
}
}
This is my function which takes the input. This is my Player Settings enter image description here enter image description here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
