- Home /
Convert touch to mouse down & drag
var thing = new GameObject[5]; var line = new String[5];
function Update () {
for(touch in iPhoneInput.touches){
if (touch.phase == iPhoneTouchPhase.Moved || touch.phase == iPhoneTouchPhase.Began)
{
thing[touch.fingerId].transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x, touch.position.y, 5));
}
if (touch.phase != iPhoneTouchPhase.Ended && touch.phase != iPhoneTouchPhase.Canceled)
{
line[touch.fingerId] = touch.fingerId + " (" + touch.phase +") "+ " " + touch.position.ToString () + "";
}
else {
line[touch.fingerId] = "";
}
}
}
function OnGUI () { GUI.color = Color(0,0.9,0); GUI.Label (Rect (20, 35, 500, 20), line[0]); GUI.Label (Rect (20, 50, 500, 20), line[1]); GUI.Label (Rect (20, 65, 500, 20), line[2]); GUI.Label (Rect (20, 80, 500, 20), line[3]); GUI.Label (Rect (20, 95, 500, 20), line[4]);
}
how can i change this to when mouse down move object then when drag render the line color?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613114348im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
iOS Mobile - Mouse Input vs Touch Input 1 Answer
Simulate touch with mouse 6 Answers
Need Help, Rotating a wheel with touch or using the mouse 2 Answers
Mobile controls, gui mouse problem. 0 Answers
Simulating mouse click/screen touch using Joypad button 0 Answers