private void UpdateDesktop(TouchReceiver receiver) { for(int i = 0; i<2; i++) { if(Input.GetMouseButtonDown(i)) receiver.OnTouchBegin(i); if(Input.GetMouseButton(i)) receiver.OnTouchStay(i); if(Input.GetMouseButtonUp(i)) receiver.OnTouchEnd(i); } }
private void UpdateAndroid(TouchReceiver receiver) { for(int i = 0; i<Input.touchCount; i++) { Touch t = Input.GetTouch(i); switch(t.phase) { case TouchPhase.Began: if(waiting) break; receiver.OnTouchBegin(t.fingerId); break; case TouchPhase.Moved: //case TouchPhase.Stationary: if(waiting) break; receiver.OnTouchStay(t.fingerId); break; case TouchPhase.Ended: case TouchPhase.Canceled: if(waiting) { waiting = false; //HACK, C# Y U no break from switch here? return; } receiver.OnTouchEnd(t.fingerId); break; } } }
//Even after all this crazyness, it's still not quite right private void UpdateAndroid(TouchReceiver receiver) { int appID; for(int i = 0; i<Input.touchCount; i++) { Touch t = Input.GetTouch(i); switch(t.phase) { case TouchPhase.Began: if(waiting) break; appID = NextID(); touchMap.Add(appID); //print("Begin(b) " + i + ", " + appID + ", " + (touchMap.Count-1) ); print("Touch: " + t.fingerId); touchCount++; receiver.OnTouchBegin(appID); break; case TouchPhase.Moved: //case TouchPhase.Stationary: if(waiting) break; appID = touchMap[i]; receiver.OnTouchStay(touchMap[i]); break; case TouchPhase.Ended: case TouchPhase.Canceled: if(waiting) { waiting = false; //HACK, C# Y U no break from switch here? return; } touchCount--; appID = touchMap[i]; //print("Ended(b) " + i + ", " + appID + ", " + (touchMap.Count-1) ); receiver.OnTouchEnd(appID); if(appID<nextAppID) nextAppID = appID; RemoveIndex(i); break; } } }