public void MyUpdate() { MicroTouch[] mts = MicroTouch.GatherMicroTouches(); foreach (ProximityButton pb in pbses) { pb.prevFingerDown = pb.fingerDown; pb.fingerDown = false; } foreach (MicroTouch t in mts) { Vector2 pos = new Vector2(t.position.x, Screen.height - t.position.y); ProximityButton pbClosest = null; float distClosest = 0; foreach (ProximityButton pb in pbses) { float distance = Vector3.Distance(pb.position, pos); if (distance < diameter) { if ((pbClosest == null) || (distance < distClosest)) { pbClosest = pb; distClosest = distance; } } } if (pbClosest != null) { pbClosest.fingerDown = true; } } }
void Update() { output = Vector3.zero; outputRaw = Vector3.zero; if (Time.timeScale == 0) { return; } bool fingerDownNext = false; MicroTouch[] mts = MicroTouch.GatherMicroTouches(); foreach (MicroTouch t in mts) { Vector2 pos = new Vector2(t.position.x, Screen.height - t.position.y); if (r_downable.Contains(pos)) { if (!fingerDown) { if (t.phase == TouchPhase.Began) { beganTime = Time.time; fingerDown = true; fingerDownNext = true; fingerId = t.fingerId; v2down = pos; r_button_ring.x = v2down.x - r_button_ring.width / 2; r_button_ring.y = v2down.y - r_button_ring.height / 2; r_button_finger.x = pos.x - r_button_finger.width / 2; r_button_finger.y = pos.y - r_button_finger.height / 2; UpdatePosition(pos); CheckConstraints(); } } } if (fingerDown) { if (t.fingerId == fingerId) { if ((t.phase == TouchPhase.Ended) || (t.phase == TouchPhase.Canceled)) { if (Time.time - beganTime < 0.2f) { detectedTap = true; } } else { fingerDownNext = true; UpdatePosition(pos); r_button_finger.x = pos.x - r_button_finger.width / 2; r_button_finger.y = pos.y - r_button_finger.height / 2; CheckConstraints(); } } } } OverlayStandardInputAxes(); fingerDown = fingerDownNext; }