public ProximityButton AddButton(string label, Vector2 position) { ProximityButton pb = new ProximityButton(label, position); pbses.Add(pb); return(pb); }
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; } } }