void pointerReceivedHandler(TouchEventData touchEvent) { lock (curAvaiPointers.AccessLock) { curAvaiPointers.CriticData = touchEvent.AvaiPointers; } }
public void PushEvent(TouchEventData data, IWidget target) { if (data.EventType == TouchEventType.Gestured || data.EventType == TouchEventType.Pressed) { CheckPopUpClosing(data.Position); } }
/// <summary> /// 设置附加事件 /// </summary> /// <param name="eventArgs">事件参数</param> private void SetEvent(XElement eventArgs) { TouchEventData.Clear(); new AppendEvent(this).SetEvent(eventArgs); //缓存 XmlEvent = eventArgs; }
protected override bool OnTouchEvent(TouchEventData e) { //Game mode if (gameMode != null && gameMode.ProcessInputMessage(this, new InputMessageTouch(e))) { return(true); } return(base.OnTouchEvent(e)); }
private void OnTouch(Part sender, TouchEventData eventData) { if (sender.partType == PartType.Body) { Part otherPart = eventData.otherPart; if (otherPart.partManager.OwnerFaction == PlayerFaction.People && otherPart.partType == PartType.RightHand) { ExitActivity(); } } }
/// <summary> /// [静的メソッド] /// Windowsメッセージからタッチイベントデータを取得する /// </summary> /// <param name="winMessage">WindowsMessage </param> /// <returns> タッチイベントデータ( メッセージがタッチ操作ではない場合は空を返す )</returns> public static TouchEventData[] GetTouchEventData(Message winMessage) { // タッチ操作ではないWindowsメッセージの場合は空を返す if (winMessage.Msg != WM_TOUCH) { return(new TouchEventData[0]); } int inputCount = (int)(winMessage.WParam.ToInt32() & 0xFFFF); var inputs = new TouchEventData[inputCount]; bool result = GetTouchInputInfo(winMessage.LParam, inputCount, inputs, Marshal.SizeOf(inputs[0])); return(inputs); }
private void TwoFingerTransformedHandler(object sender, System.EventArgs e) { //Log.Status ("TouchEventManager", "TwoFingerTransformedHandler: {0}", m_TwoFingerMoveGesture.DeltaPosition); if (m_Active) { TouchEventData dragEventToFire = null; foreach (var kp in m_DragEvents) { if (kp.Key == 2) { for (int i = 0; i < kp.Value.Count; ++i) { TouchEventData dragEventData = kp.Value[i]; if (string.IsNullOrEmpty(dragEventData.DragCallback)) { Log.Warning("TouchEventManager", "Removing invalid event receiver from TwoFingerDrag"); kp.Value.RemoveAt(i--); continue; } if (dragEventToFire == null) { dragEventToFire = dragEventData; } else { if (dragEventData.SortingLayer > dragEventToFire.SortingLayer || (dragEventToFire.SortingLayer == dragEventData.SortingLayer && !dragEventToFire.IsInside)) { dragEventToFire = dragEventData; } else { //do nothing } } } } } if (dragEventToFire != null) { EventManager.Instance.SendEvent(dragEventToFire.DragCallback, m_TwoFingerMoveGesture); } EventManager.Instance.SendEvent("OnDragTwoFingerFullscreen", m_TwoFingerMoveGesture); } }
void TriggerTouchEvent(Vector2 deltaIncrement) { var touchEventData = new TouchEventData(); touchEventData.TouchState = _touchState; touchEventData.CurPosition = _curPanPosition; touchEventData.DeltaIncrement = deltaIncrement; touchEventData.InitPosition = _initPanPosition; touchEventData.PanType = _panType; touchEventData.CurDirection = (_curPanPosition - _initPanPosition).normalized; touchEventData.TotalPanScreenPercentageSize = Vector2.Distance(_initPanPosition, _curPanPosition) / Screen.height; EventManager.Instance.TriggerEvent(TouchEvent.EventName, touchEventData); }
void MoveDirectionArrow(TouchEventData touchEventData) { //Debug.Log("DISTANCE : " + touchEventData.TotalPanScreenPercentageSize); if (touchEventData.TotalPanScreenPercentageSize < _minScreenPercentageToMove) { return; } var angles = Vector2.SignedAngle(touchEventData.CurDirection, Vector2.up); angles *= _directionAngleIncrement; angles += 180f; //Debug.Log("ANGLES " + angles + " DOT PROD "); UpdateRotation(angles); }
private void OnTouch(Part sender, TouchEventData eventDate) { // 如果是服务器则正常做处理 if (Server.ins.enabled) { PlayerFaction onwerFaction = attrManager.faction; Part otherPart = eventDate.otherPart; PartType otherPartType = otherPart.partType; if (onwerFaction == PlayerFaction.Ghost && otherPartType == PartType.Body && !otherPart.partManager.IsOwnerBinging) { //GameControler.ins.SwitchFaction(attrManager, otherPart.partManager.attrManager); Server.ins.SwitchFaction(attrManager, otherPart.partManager.attrManager); } else if (onwerFaction == PlayerFaction.People && !IsOwnerBinging && otherPartType == PartType.RightHand) { //GameControler.ins.SwitchFaction(otherPart.partManager.attrManager, attrManager); Server.ins.SwitchFaction(otherPart.partManager.attrManager, attrManager); } } }
public bool PerformTouchEvent(TouchEventData e) { CheckCachedParameters(); UpdateCachedCoverControls(); if (capturedControl != null && capturedControl.ParentContainer == null) { capturedControl = null; } if (focusedControl != null && focusedControl.ParentContainer == null) { focusedControl = null; } if (capturedControl != null) { return(capturedControl.CallTouchEvent(e)); } return(CallTouchEvent(e)); }
/// <summary> /// To check equality of the same Touch Event Data /// </summary> /// <param name="obj">Object to check equality</param> /// <returns>True if objects are equal</returns> public override bool Equals(object obj) { bool isEqual = false; TouchEventData touchEventData = obj as TouchEventData; if (touchEventData != null) { isEqual = (touchEventData.Collider == this.Collider && touchEventData.GameObjectAttached == this.GameObjectAttached && touchEventData.IsInside == this.IsInside && touchEventData.SortingLayer == this.SortingLayer && touchEventData.DragCallback == this.DragCallback && touchEventData.TapCallback == this.TapCallback); } else { isEqual = base.Equals(obj); } return(isEqual); }
private void WsClient_OnMessage(object sender, WebSocketSharp.MessageEventArgs e) { if (e.IsText) { string msg = e.Data; //Debug.Log(msg); try { //Debug.Log(msg); TouchEventData touchEvent = TouchEventData.ParseToucEventFromJsonString(msg); if (pointerReceivedListener != null) { pointerReceivedListener(touchEvent); } gestureRecognizer.RecognizeGesture(touchEvent); //string decodedMsg = "From JSON: "; //decodedMsg += string.Format("Event type:{0};Pointers count: {1};AvaiPointers:{2}", touchEvent.EventType, touchEvent.PointerCount, touchEvent.AvaiPointers.Length); } catch (Exception ex) { Debug.Log("JSON Parsing Error:" + ex.Message); } } }
public void RecognizeGesture(TouchEventData curTouchEvent) { TouchGesture recognizedGesture = new TouchGesture(); //if there are more than one fingers, there is no chance for a single tap if (curTouchEvent.PointerCount > 1) { stayStillSingleTouchDown = null; } if (curTouchEvent.PointerCount == 1 && (Math.Abs(curTouchEvent.AvaiPointers[0].RelVeloX) > 0.0001 || Math.Abs(curTouchEvent.AvaiPointers[0].RelVeloY) > 0.0001)) { stayStillSingleTouchDown = null; } //process cases with multi fingers if (curTouchEvent.PointerCount == 5)// && curTouchEvent.EventType == 0) { recognizedGesture.GestureType = TouchGestureType.FIVE_POINTERS; informGestureRecognizedEvent(recognizedGesture); return; } //recognizing scaling virtual pad gesture if (curTouchEvent.PointerCount == 3 && curTouchEvent.EventType == 1) { if (recognizePadPanningGesture(curTouchEvent.AvaiPointers, out recognizedGesture)) { } else { } informGestureRecognizedEvent(recognizedGesture); } //recognizing pad translating gesture if (curTouchEvent.PointerCount == 2) { //two fingers moving in the same direction => translating the virtual pad if (curTouchEvent.AvaiPointers[0].RelVeloX * curTouchEvent.AvaiPointers[1].RelVeloX > 0 && curTouchEvent.AvaiPointers[0].RelVeloY * curTouchEvent.AvaiPointers[1].RelVeloY > 0) { float avgVeloX = (curTouchEvent.AvaiPointers[0].RelVeloX + curTouchEvent.AvaiPointers[1].RelVeloX) / 2; float veloXDif = Math.Abs(curTouchEvent.AvaiPointers[0].RelVeloX - curTouchEvent.AvaiPointers[1].RelVeloX); float avgVeloY = (curTouchEvent.AvaiPointers[0].RelVeloY + curTouchEvent.AvaiPointers[1].RelVeloY) / 2; float veloYDif = Math.Abs(curTouchEvent.AvaiPointers[0].RelVeloY - curTouchEvent.AvaiPointers[1].RelVeloY); //if(veloXDif/avgVeloX < 0.2 && veloYDif/avgVeloY<0.2) //{ recognizedGesture.GestureType = TouchGestureType.PAD_TRANSLATING; Vector2 translateVelo = new Vector2(); translateVelo.x = avgVeloX / TOUCH_REFRESH_RATE; translateVelo.y = avgVeloY / TOUCH_REFRESH_RATE; recognizedGesture.MetaData = translateVelo; informGestureRecognizedEvent(recognizedGesture); return; } //two fingers moving in opposite direction => object scaling if (curTouchEvent.AvaiPointers[0].RelVeloX * curTouchEvent.AvaiPointers[1].RelVeloX < 0 || curTouchEvent.AvaiPointers[0].RelVeloY * curTouchEvent.AvaiPointers[1].RelVeloY < 0) { recognizedGesture.GestureType = TouchGestureType.OBJECT_SCALING; informGestureRecognizedEvent(recognizedGesture); return; } } //process when there is only one finger if (curTouchEvent.EventType == 0 && curTouchEvent.PointerCount == 1) { stayStillSingleTouchDown = new RecordedTouch(); stayStillSingleTouchDown.TouchPointers.Add(TouchPointerData.Create(curTouchEvent.AvaiPointers[0])); recognizedGesture.GestureType = TouchGestureType.SINGLE_TOUCH_DOWN; recognizedGesture.MetaData = TouchPointerData.Create(curTouchEvent.AvaiPointers[0]); informGestureRecognizedEvent(recognizedGesture); return; } if (curTouchEvent.EventType == 2 && curTouchEvent.PointerCount == 0) { //first inform a non gesture for client to process if needed TouchGesture non_gesture = new TouchGesture(); informGestureRecognizedEvent(non_gesture); RecordedTouch recordedTouchUp = new RecordedTouch(); if (stayStillSingleTouchDown != null) { TimeSpan touchDuration = recordedTouchUp.TimeStamp.Subtract(stayStillSingleTouchDown.TimeStamp); if (touchDuration.TotalMilliseconds < 200) { recognizedGesture.GestureType = TouchGestureType.SINGLE_TAP; recognizedGesture.MetaData = new Vector2(stayStillSingleTouchDown.TouchPointers[0].RelX, stayStillSingleTouchDown.TouchPointers[0].RelY); } stayStillSingleTouchDown = null; informGestureRecognizedEvent(recognizedGesture); return; } } }
public void OnTouchStop(TouchEventData eventData, Vector2 TouchData) => touchStatus[(int)eventData.SourceId] = $"Stop : {TouchData}";
public void OnTouchUpdated(TouchEventData eventData, Vector2 TouchData) => touchStatus[(int)eventData.SourceId] = $"Updated : {TouchData}";
private void DoubleTapGesture_Tapped(object sender, System.EventArgs e) { if (m_Active) { #if ENABLE_DEBUGGING Log.Debug("TouchEventManager", "DoubleTapGesture_Tapped: {0} - {1}", m_DoubleTapGesture.ScreenPosition, m_DoubleTapGesture.NumTouches); #endif TouchEventData tapEventToFire = null; RaycastHit hit = default(RaycastHit); RaycastHit hitToFire = default(RaycastHit); foreach (var kp in m_DoubleTapEvents) { Ray rayForTab = MainCamera.ScreenPointToRay(m_DoubleTapGesture.ScreenPosition); bool isHitOnLayer = Physics.Raycast(rayForTab, out hit, Mathf.Infinity, kp.Key); for (int i = 0; i < kp.Value.Count; ++i) { TouchEventData tapEventData = kp.Value[i]; if (kp.Value[i].Collider == null) { Log.Warning("TouchEventManager", "DoubleTapGesture_Tapped: Removing invalid collider event receiver from TapEventList"); kp.Value.RemoveAt(i--); continue; } if (string.IsNullOrEmpty(tapEventData.TapCallback)) { Log.Warning("TouchEventManager", "Removing invalid event receiver from TapEventList"); kp.Value.RemoveAt(i--); continue; } if (isHitOnLayer && hit.collider.transform == tapEventData.Collider.transform && tapEventData.IsInside) { //Tapped inside the object if (tapEventToFire == null) { tapEventToFire = tapEventData; hitToFire = hit; } else { if (tapEventData.SortingLayer > tapEventToFire.SortingLayer || (tapEventToFire.SortingLayer == tapEventData.SortingLayer && !tapEventToFire.IsInside)) { tapEventToFire = tapEventData; hitToFire = hit; } else { //do nothing } } } else if ((!isHitOnLayer || hit.collider.transform != tapEventData.Collider.transform) && !tapEventData.IsInside) { //Tapped outside the object if (tapEventToFire == null) { tapEventToFire = tapEventData; hitToFire = hit; } else { if (tapEventData.SortingLayer > tapEventToFire.SortingLayer) { tapEventToFire = tapEventData; hitToFire = hit; } else { //do nothing } } } else { //do nothing } } } if (tapEventToFire != null) { EventManager.Instance.SendEvent(tapEventToFire.TapCallback, m_DoubleTapGesture, hitToFire); } EventManager.Instance.SendEvent("OnDoubleTap", m_DoubleTapGesture); } }
public InputMessageTouch(TouchEventData touchEvent) { this.touchEvent = touchEvent; }
private void OneFingerTransformedHandler(object sender, System.EventArgs e) { RaycastHit hit = default(RaycastHit); RaycastHit2D hit2D = default(RaycastHit2D); //Log.Status ("TouchEventManager", "oneFingerManipulationTransformedHandler: {0}", m_OneFingerMoveGesture.DeltaPosition); if (m_Active) { TouchEventData dragEventToFire = null; Ray rayForDrag = MainCamera.ScreenPointToRay(m_OneFingerMoveGesture.ScreenPosition); foreach (var kp in m_DragEvents) { if (kp.Key == 1) { for (int i = 0; i < kp.Value.Count; ++i) { TouchEventData dragEventData = kp.Value[i]; if (string.IsNullOrEmpty(dragEventData.DragCallback)) { Log.Warning("TouchEventManager", "Removing invalid event receiver from OneFingerDrag"); kp.Value.RemoveAt(i--); continue; } bool hasDragOnObject = false; //If we can drag the object, we should check that whether there is a raycast or not! if (dragEventData.CanDragObject) { bool isHitOnLayer = Physics.Raycast(rayForDrag, out hit, Mathf.Infinity, 1 << dragEventData.GameObjectAttached.layer); Transform hitTransform = null; if (isHitOnLayer) { hitTransform = hit.transform; } else { hit2D = Physics2D.Raycast(rayForDrag.origin, rayForDrag.direction, Mathf.Infinity, 1 << dragEventData.GameObjectAttached.layer); if (hit2D.collider != null) { isHitOnLayer = true; hitTransform = hit2D.transform; } } if (isHitOnLayer && dragEventData.HasTouchedOn(hitTransform) && dragEventData.IsInside) { hasDragOnObject = true; } else if (!isHitOnLayer && !dragEventData.IsInside) { hasDragOnObject = true; } else { //do nothing - we were checking that draggable object that we touched! } } if (hasDragOnObject || !dragEventData.CanDragObject) { //They are all fullscreen drags! if (dragEventToFire == null) { dragEventToFire = dragEventData; } else { if (dragEventData.SortingLayer > dragEventToFire.SortingLayer || (dragEventToFire.SortingLayer == dragEventData.SortingLayer && !dragEventToFire.IsInside)) { dragEventToFire = dragEventData; } else { //do nothing } } } } } } if (dragEventToFire != null) { EventManager.Instance.SendEvent(dragEventToFire.DragCallback, m_OneFingerMoveGesture, hit, hit2D); } EventManager.Instance.SendEvent("OnDragOneFingerFullscreen", m_OneFingerMoveGesture); } }
public void OnTouchUpdated(TouchEventData eventData, Vector2 TouchData) => _text.text = "OnTouchUpdated";
public void OnTouchStop(TouchEventData eventData, Vector2 TouchData) => _text.text = "OnTouchStop";
public void OnTouchStart(TouchEventData eventData, Vector2 TouchData) { touchStatus[(int)eventData.SourceId] = $"Start : {TouchData}"; }
private void TapGesture_Tapped(object sender, System.EventArgs e) { if (m_Active) { //Log.Status("TouchEventManager", "TapGesture_Tapped: {0}", m_TapGesture.ScreenPosition); TouchEventData tapEventToFire = null; RaycastHit hit = default(RaycastHit); foreach (var kp in m_TapEvents) { Ray rayForTab = MainCamera.ScreenPointToRay(m_TapGesture.ScreenPosition); bool isHitOnLayer = Physics.Raycast(rayForTab, out hit, Mathf.Infinity, kp.Key); for (int i = 0; i < kp.Value.Count; ++i) { TouchEventData tapEventData = kp.Value[i]; if (tapEventData.TapCallback == Constants.Event.NONE) { Log.Warning("TouchEventManager", "Removing invalid event receiver from TapEventList"); kp.Value.RemoveAt(i--); continue; } if (isHitOnLayer && hit.collider.transform == tapEventData.Collider.transform && tapEventData.IsInside) { //Tapped inside the object if (tapEventToFire == null) { tapEventToFire = tapEventData; } else { if (tapEventData.SortingLayer > tapEventToFire.SortingLayer || (tapEventToFire.SortingLayer == tapEventData.SortingLayer && !tapEventToFire.IsInside)) { tapEventToFire = tapEventData; } else { //do nothing } } } else if ((!isHitOnLayer || hit.collider.transform != tapEventData.Collider.transform) && !tapEventData.IsInside) { //Tapped outside the object if (tapEventToFire == null) { tapEventToFire = tapEventData; } else { if (tapEventData.SortingLayer > tapEventToFire.SortingLayer) { tapEventToFire = tapEventData; } else { //do nothing } } } else { //do nothing } } } if (tapEventToFire != null && tapEventToFire.TapCallback != Constants.Event.NONE) { EventManager.Instance.SendEvent(tapEventToFire.TapCallback, m_TapGesture, hit); } //tapEventToFire.TapCallback(m_TapGesture, tapEventToFire.Collider.transform); } }