Touch ot1;
Touch ot2;
float scale;
void Start () {
}
void Update () {
if (Input.touchCount > 0) {
if (Input.touchCount == 1) {
Vector2 v = Input.GetTouch (0).deltaPosition;
transform.Rotate (v.y, -v.x, 0, Space.World);
}
if (Input.touchCount > 1) {
Touch t1 = Input.GetTouch (0);
Touch t2 = Input.GetTouch (1);
if (t2.phase == TouchPhase.Began) {
ot1 = t1;
ot2 = t2;
return;
}
float d1 = Vector2.Distance (t1.position, t2.position);
float d2 = Vector2.Distance (ot1.position, ot2.position);
scale =( d1 - d2)/100f;
ot1 = t1;
ot2 = t2;
}
}else{
if(Input.GetMouseButton(0)){
transform.Rotate (Input.GetAxis ("Mouse Y")*10f, -Input.GetAxis ("Mouse X")*10f, 0, Space.World);
}
scale = Input.mouseScrollDelta.y/10f;
}
float s=transform.localScale.x+scale;
if(s>0.05f&&s<6f){
transform.localScale = new Vector3 (s, s, s);
}
}