I'm new to Unity and I'm a bit surprised that there is no optional auto-conversion of basic touch actions to mouse. Well, at least none that I've found after 2 hours searching.. Anyways.. I have the following script to drag a 2D sprite:
void OnMouseDrag()
{
if (dragEnabled) {
Vector3 point = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, (transform.position.z - Camera.main.transform.position.z)));
point.z = transform.position.z;
transform.position = point;
}
}
Pretty straighforward.. But now I need to make this work for touch, but every solution I found are either from 2011, fail to work and/or are dozens of lines long..
Is there a simple way to "convert" this to mobile, or, even better, make one solution that works for both cases?