androidunity-game-engineonmouseup

Equivalent of OnMouseUp() in Unity3D


I basically have this code. I got performance errors in unity3d when I tried to use OnMouseUp() function. I have no idea how to use Touch functions for android.

void OnMouseUp()
{
    DetectCollider.IfInMain = false;
    DetectCollider.Score = 0.00f;
    MainMenux.SetActive(false);
    Mech.transform.rotation = Quaternion.Euler(270, 180, 0);
    DetectCollider.Speed = 100;
    ScoreCountTurn = true;
}

Solution

  • Try something like this. It should work for android also.

      void Update() {
        if (Input.GetMouseButtonUp(0)) 
        {
            DoStuff();
        }
      }
    

    Or you can use Input.GetTouch(), and then check TouchPhase, instead of GetMouseButtonUp(). And support multitouching going this way.

      void Update() {
        if (Input.GetTouch(0).phase == TouchPhase.ended) 
        {
            DoStuff();
        }
      }