Vector2 V1, V2; float Distance_now, Distance_last; void Update() { if (Input.touchCount == 0) { Debug.Log("s"); Distance_now = 0; Distance_last = 0; } if (Input.touchCount == 1) { Debug.Log("1"); Distance_now = 0; Distance_last = 0; //旋转 } if (Input.touchCount == 2) { if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(1).phase == TouchPhase.Moved) { V1 = Input.GetTouch(0).position; V2 = Input.GetTouch(1).position; Distance_now = Vector2.Distance(V1,V2); if (Distance_now > Distance_last) { //放大 transform.localScale *= 1.03f; } if (Distance_now < Distance_last) { transform.localScale *= 0.97f; //缩小 } Distance_last = Distance_now; } } }