public void OnEvent(TouchPoint touchPoint) { Vector3 screenPosition = RawTouchPosToCanvasCoords(touchPoint.GetPosition()); int touchID = touchPoint.GetID(); //Debug.Log(touchPoint.GetPosition() + " " + touchPoint.GetID() + " " + touchPoint.GetGesture()); if (!touchList.ContainsKey(touchID)) { if (touchPoint.GetGesture() == EventBase.Type.Down) { GameObject visualMarker = Instantiate(touchPointPrefab); visualMarker.name = "TouchPoint " + touchID; visualMarker.transform.SetParent(transform); // Update position with new touch data visualMarker.transform.position = screenPosition; visualMarker.transform.localScale = Vector3.one * 10; touchPoint.SetObjectTouched(visualMarker); touchPoint.Update(screenPosition, EventBase.Type.Down); touchList.Add(touchID, touchPoint); } } else { if (touchPoint.GetGesture() == EventBase.Type.Move) { // Get the existing touch data TouchPoint existingTouchPoint = (TouchPoint)touchList[touchID]; GameObject visualMarker = existingTouchPoint.GetObjectTouched(); // Update position with new touch data visualMarker.transform.position = RawTouchPosToCanvasCoords(touchPoint.GetPosition()); visualMarker.transform.localScale = Vector3.one * 10; existingTouchPoint.Update(screenPosition, EventBase.Type.Move); touchList[touchID] = existingTouchPoint; } else if (touchPoint.GetGesture() == EventBase.Type.Up) { // Get the existing touch data TouchPoint existingTouchPoint = (TouchPoint)touchList[touchID]; GameObject visualMarker = existingTouchPoint.GetObjectTouched(); existingTouchPoint.Update(screenPosition, EventBase.Type.Up); // Remove the TouchPoint Destroy(visualMarker); touchList.Remove(touchID); } } }