Search Unity

2D mobile touch error in build games

Discussion in '2D' started by kvnchua, Feb 24, 2017.

  1. kvnchua

    kvnchua

    Joined:
    Apr 24, 2015
    Posts:
    6
    Iam having problem on fixing the hold touch input on my build game. The code works on remote but never works on build games.Can anyone help me? Here is the code:
    Code (CSharp):
    1. if (Input.touchCount > 0)
    2.         {
    3.             Touch touch = Input.GetTouch(0);
    4.             acumulatedTime += touch.deltaTime;
    5.  
    6.             if (touch.phase == TouchPhase.Began)
    7.             {
    8.                 if (acumulatedTime < holdTime)
    9.                 {
    10.                     //touch code
    11.                 }
    12.             }
    13.  
    14.             if(touch.phase == TouchPhase.Stationary)
    15.             {
    16.                 if (acumulatedTime >= holdTime)
    17.                 {
    18.                     //hold code here
    19.                 }
    20.             }
    21.  
    22.             if (touch.phase == TouchPhase.Ended)
    23.             {
    24.                 acumulatedTime = 0;
    25.             }
    26.         }
    27.     }