internal void Process(Transform transform, Camera renderCamera, dfList <Touch> touches, bool retainFocus) { for (int i = 0; i < touches.Count; i++) { Touch item = touches[i]; Ray ray = renderCamera.ScreenPointToRay(item.position); float single = renderCamera.farClipPlane - renderCamera.nearClipPlane; RaycastHit[] raycastHitArray = Physics.RaycastAll(ray, single, renderCamera.cullingMask); dfInputManager.controlUnderMouse = this.clipCast(transform, raycastHitArray); if (dfInputManager.controlUnderMouse == null && item.phase == TouchPhase.Began) { this.untracked.Add(item.fingerId); } else if (!this.untracked.Contains(item.fingerId)) { dfInputManager.TouchInputManager.TouchRaycast touchRaycast = new dfInputManager.TouchInputManager.TouchRaycast(dfInputManager.controlUnderMouse, item, ray); dfInputManager.TouchInputManager.ControlTouchTracker controlTouchTracker = this.tracked.FirstOrDefault <dfInputManager.TouchInputManager.ControlTouchTracker>((dfInputManager.TouchInputManager.ControlTouchTracker x) => x.IsTrackingFinger(touchRaycast.FingerID)); if (controlTouchTracker == null) { bool flag = false; int num = 0; while (num < this.tracked.Count) { if (!this.tracked[num].Process(touchRaycast)) { num++; } else { flag = true; break; } } if (!flag && dfInputManager.controlUnderMouse != null) { if (!this.tracked.Any <dfInputManager.TouchInputManager.ControlTouchTracker>((dfInputManager.TouchInputManager.ControlTouchTracker x) => x.control == dfInputManager.controlUnderMouse)) { if (dfInputManager.controlUnderMouse == null) { Debug.Log(string.Concat("Tracking touch with no control: ", item.fingerId)); } dfInputManager.TouchInputManager.ControlTouchTracker controlTouchTracker1 = new dfInputManager.TouchInputManager.ControlTouchTracker(this.manager, dfInputManager.controlUnderMouse); this.tracked.Add(controlTouchTracker1); controlTouchTracker1.Process(touchRaycast); } } } else { controlTouchTracker.Process(touchRaycast); } } else if (item.phase == TouchPhase.Ended) { this.untracked.Remove(item.fingerId); } } }
private bool canFireClickEvent(dfInputManager.TouchInputManager.TouchRaycast info, dfInputManager.TouchInputManager.TouchRaycast touch) { if (this.manager.TouchClickRadius <= 0) { return(true); } float single = Vector2.Distance(info.position, touch.position); return(single < (float)this.manager.TouchClickRadius); }
public bool Process(dfInputManager.TouchInputManager.TouchRaycast info) { if (this.IsDragging) { if (!this.capture.Contains(info.FingerID)) { return(false); } if (info.Phase == TouchPhase.Stationary) { return(true); } if (info.Phase == TouchPhase.Canceled) { this.control.OnDragEnd(new dfDragEventArgs(this.control, dfDragDropState.Cancelled, this.dragData, info.ray, info.position)); this.dragState = dfDragDropState.None; this.touches.Clear(); this.capture.Clear(); return(true); } if (info.Phase != TouchPhase.Ended) { return(true); } if (info.control == null || info.control == this.control) { this.control.OnDragEnd(new dfDragEventArgs(this.control, dfDragDropState.CancelledNoTarget, this.dragData, info.ray, info.position)); this.dragState = dfDragDropState.None; this.touches.Clear(); this.capture.Clear(); return(true); } dfDragEventArgs dfDragEventArg = new dfDragEventArgs(info.control, dfDragDropState.Dragging, this.dragData, info.ray, info.position); info.control.OnDragDrop(dfDragEventArg); if (!dfDragEventArg.Used || dfDragEventArg.State != dfDragDropState.Dropped) { dfDragEventArg.State = dfDragDropState.Cancelled; } dfDragEventArgs dfDragEventArg1 = new dfDragEventArgs(this.control, dfDragEventArg.State, this.dragData, info.ray, info.position) { Target = info.control }; this.control.OnDragEnd(dfDragEventArg1); this.dragState = dfDragDropState.None; this.touches.Clear(); this.capture.Clear(); return(true); } if (!this.touches.ContainsKey(info.FingerID)) { if (info.control != this.control) { return(false); } this.touches[info.FingerID] = info; if (this.touches.Count == 1) { this.control.OnMouseEnter(info); if (info.Phase == TouchPhase.Began) { this.capture.Add(info.FingerID); this.control.OnMouseDown(info); } return(true); } if (info.Phase == TouchPhase.Began) { this.control.OnMouseUp(info); this.control.OnMouseLeave(info); List <Touch> activeTouches = this.getActiveTouches(); dfTouchEventArgs dfTouchEventArg = new dfTouchEventArgs(this.control, activeTouches, info.ray); this.control.OnMultiTouch(dfTouchEventArg); } return(true); } if (info.Phase == TouchPhase.Canceled || info.Phase == TouchPhase.Ended) { dfInputManager.TouchInputManager.TouchRaycast item = this.touches[info.FingerID]; this.touches.Remove(info.FingerID); if (this.touches.Count == 0) { if (this.capture.Contains(info.FingerID)) { if (this.canFireClickEvent(info, item) && info.control == this.control) { if (info.touch.tapCount <= 1) { this.control.OnClick(info); } else { this.control.OnDoubleClick(info); } } this.control.OnMouseUp(info); } this.control.OnMouseLeave(info); this.capture.Remove(info.FingerID); return(true); } this.capture.Remove(info.FingerID); if (this.touches.Count == 1) { dfTouchEventArgs dfTouchEventArg1 = this.touches.Values.First <dfInputManager.TouchInputManager.TouchRaycast>(); this.control.OnMouseEnter(dfTouchEventArg1); this.control.OnMouseDown(dfTouchEventArg1); return(true); } } if (this.touches.Count > 1) { List <Touch> touches = this.getActiveTouches(); dfTouchEventArgs dfTouchEventArg2 = new dfTouchEventArgs(this.control, touches, info.ray); this.control.OnMultiTouch(dfTouchEventArg2); return(true); } if (!this.IsDragging && info.Phase == TouchPhase.Stationary) { if (info.control != this.control) { return(false); } this.control.OnMouseHover(info); return(true); } if ((!this.capture.Contains(info.FingerID) || this.dragState != dfDragDropState.None ? false : info.Phase == TouchPhase.Moved)) { dfDragEventArgs dfDragEventArg2 = info; this.control.OnDragStart(dfDragEventArg2); if (dfDragEventArg2.State == dfDragDropState.Dragging && dfDragEventArg2.Used) { this.dragState = dfDragDropState.Dragging; this.dragData = dfDragEventArg2.Data; return(true); } this.dragState = dfDragDropState.Denied; } if (!(info.control != this.control) || this.capture.Contains(info.FingerID)) { this.control.OnMouseMove(info); return(true); } this.control.OnMouseLeave(info); this.touches.Remove(info.FingerID); return(true); }