I am stuck with an issue of moving the slider on android mobiles with finger touch event while developing pong game in unity 3D, though its working fine for pc.

This game is developed in 2D environment... please help me if anyone have available solution to this issue enter image description here

Actually I have developed this game for pc so I have code for the movement of slider accordingly as below:

var keyup:KeyCode;
var keydown:KeyCode;
var speed:float=1;

function Update () {
    else if(Input.GetKey(keydown))

But now i want to use this game for android mobiles.


You can create a script attached to the object you want to drag and adapt your code to work inside OnMouseDown() & OnMouseDrag()

  • \$\begingroup\$ Do OnMouseDown() & OnMouseDrag() will work for android mobile devices ?? \$\endgroup\$ Jul 10 '15 at 7:11
  • \$\begingroup\$ Yes they will work fine. Input.GetKeyDown(KeyCode.Mouse0) will also work for a single tap/touch event \$\endgroup\$ Jul 10 '15 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.