/// effect handle private void EffectHandle(GestureEvent ge, float posX, float posY, float posZ, bool isSelected, bool isLogicCmd) { try { if (DFMUiRoot.InputMode == InputType.Joystick) { return; } UnityEngine.Vector3 effect_pos = new UnityEngine.Vector3(posX, posY, posZ); if (GestureEvent.OnSingleTap == ge) { if (isSelected) { if (!isLogicCmd) { PlayEffect(Go_Lock, effect_pos, Go_Lock_Time); } } else { PlayEffect(Go_Landmark, effect_pos, Go_Landmark_Time); HideSkillTip(); } } } catch (Exception ex) { ArkCrossEngine.LogicSystem.LogFromGfx("[Error]:Exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
public void DispatchUserAction() { if (PauseEvent) { return; } for (int i = 0; i < inputs.Length; i++) { if (inputs[i] != null) { #if DEBUG try { #endif if (inputs[i].IsActive) { inputs[i].Dispatch(model); } #if DEBUG } catch (Exception ex) { Debug.Log(ex.StackTrace); } #endif } } if (inputs.Length > 1) { GestureEvent.Dispatch(new List <UserAction>(inputs)); } }
public GestureEventCallback(string label, GestureType gestureType, bool isEnabled, GestureEvent gEvent) { callbackLabel = label; gestureListeningFor = gestureType; enabled = isEnabled; onEvent = gEvent; }
private void OnEnded() { GestureEvent handler = Ended; if (handler != null) { handler(this); } }
private void OnStarted() { GestureEvent handler = Started; if (handler != null) { handler(this); } }
public void OnGestureChange(ElementEvent e) { GestureEvent g = (GestureEvent)e; mouseDown = false; double delta = g.Scale; // if (delta > 1 && Math.Abs(delta - 1) > .05) }
public void gestureOccurs(GestureEvent e) { if (lookup.ContainsKey(e.GetType())) { WindowsInput.VirtualKeyCode ekey = lookup[e.GetType()]; //InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.RMENU, ekey); InputSimulator.SimulateKeyPress(ekey); } }
private void OnStarted() { _lastChange = DateTime.Now; GestureEvent handler = Started; if (handler != null) { handler(this); } }
// Start is called before the first frame update void Start() { if (m_OnSensorTriggered == null) { m_OnSensorTriggered = new GestureEvent(); } if (m_OnSensorUntriggered == null) { m_OnSensorUntriggered = new GestureEvent(); } }
void TowFingerMove(GestureEvent ges) { if (drawModel == DrawModel.Scale) { float s = ges.CurScale; Enity.localScale = new Vector3(s, s, s); } else if (drawModel == DrawModel.Rotate) { float a = ges.DeltaAngle; Enity.localRotation *= Quaternion.Euler(0, 0, a); } }
public GestureEvent GetEvent() { var result = new GestureEvent(); result.EventPart1 = (GestureEventType) this.Event1ComboBox.SelectedValue; result.EventPart2 = (GestureEventType) this.Event2ComboBox.SelectedValue; result.TriggerGestureName = this.TriggerGestureTextBox.Text; if (result.TriggerGestureName.CompareTo("") == 0) result.TriggerGestureName = "anything"; return result; }
/// <summary> /// 派发用户输入指令信息 /// </summary> public void DispatchUserAction() { #if UNITY_STANDALONE_WIN DispatchWin(Input.touches); #elif UNITY_EDITOR DispatchMouse(); #elif UNITY_IPHONE || UNITY_ANDROID DispatchTouch(Input.touches); #else DispatchMouse(); #endif if (PauseEvent) { return; } PhysicalScale = UISystem.PhysicalScale; if (render != null) { if (render.renderMode == RenderMode.WorldSpace) { PhysicalScale = 1; } } for (int i = 0; i < inputs.Length; i++) { if (inputs[i] != null) { #if DEBUG try { #endif inputs[i].PhysicalScale = PhysicalScale; if (inputs[i].IsActive) { inputs[i].Dispatch(PipeLine); } #if DEBUG } catch (Exception ex) { Debug.LogError(ex.StackTrace); } #endif } } if (inputs.Length > 0) { GestureEvent.Dispatch(inputs); } }
void Start() { Hands = Hands.Instance; LeftHand = Hands.LeftHand; RightHand = Hands.RightHand; LeftHandT = LeftHand.gameObject.transform; RightHandT = RightHand.gameObject.transform; LeftHandStates = new Queue <HandState>(); RightHandStates = new Queue <HandState>(); AveragePinchStrengthLeft = AveragePinchStrengthRight = new float[5] { 0f, 0f, 0f, 0f, 0f }; SlapRightG = new GestureEvent(SlapRight); }
void TowFingerMove(GestureEvent ges) { if (drawModel == DrawModel.Scale) { float s = ges.CurScale; model.data.localScale.x = s; model.data.localScale.y = s; model.data.localScale.y = s; } else if (drawModel == DrawModel.Rotate) { float a = ges.DeltaAngle; model.data.localRotation *= Quaternion.Euler(0, 0, a); } }
public GestureEvent GetEvent() { var result = new GestureEvent(); result.EventPart1 = (GestureEventType)this.Event1ComboBox.SelectedValue; result.EventPart2 = (GestureEventType)this.Event2ComboBox.SelectedValue; result.TriggerGestureName = this.TriggerGestureTextBox.Text; if (result.TriggerGestureName.CompareTo("") == 0) { result.TriggerGestureName = "anything"; } return(result); }
public void OnGestureChange(ElementEvent e) { GestureEvent g = (GestureEvent)e; mouseDown = false; double delta = g.Scale; if (delta > 1 && Math.Abs(delta - 1) > .05) { Zoom(0.95); } else { Zoom(1.05); } }
private void Awake() { if (_instance == null) { _instance = this; } else { Destroy(gameObject); } OnTap = new GestureEvent(); OnDrag = new GestureEvent(); OnSwipe = new GestureEvent(); OnEsc = new KeyEvent(); }
private void Handle(GestureEvent gestureEvent) { foreach (var transition in transitions) { if (transition.current.Equals(current) && transition.gestureEvent.Equals(gestureEvent)) { if (transition.action != null) { transition.action(); } current = transition.next; break; } } }
public override void Initial(ModelElement mod) { base.Initial(mod); model = mod; raw = model.GetComponent <RawImageElement>(); var size = model.data.sizeDelta; Width = (int)size.x; Height = (int)size.y; HalfW = Width / 2; HalfH = Height / 2; buffer = new Color[Width * Height]; gesture = EventCallBack.RegEvent <GestureEvent>(model); gesture.PointerDown = PointDown; gesture.Drag = Drag; gesture.DragEnd = DragEnd; gesture.AutoColor = false; gesture.TowFingerMove = TowFingerMove; ThreadMission.InvokeToMain(Apply, null); }
public override void Initial(FakeStruct fake, UIElement script, UIInitializer initializer) { base.Initial(fake, script, initializer); raw = Enity as HImage; raw.MainColor = Color.white; var size = Enity.SizeDelta; Width = (int)size.x; Height = (int)size.y; HalfW = Width / 2; HalfH = Height / 2; buffer = new Color[Width * Height]; gesture = Enity.RegEvent <GestureEvent>(); gesture.PointerDown = PointDown; gesture.Drag = Drag; gesture.DragEnd = DragEnd; gesture.AutoColor = false; gesture.TowFingerMove = TowFingerMove; Apply(null); }
/// <summary> /// 派发用户输入指令信息 /// </summary> void DispatchUserAction() { #if UNITY_STANDALONE_WIN DispatchWin(); #elif UNITY_EDITOR DispatchMouse(); #elif UNITY_IPHONE || UNITY_ANDROID DispatchTouch(); #else DispatchMouse(); #endif if (PauseEvent) { return; } for (int i = 0; i < inputs.Length; i++) { if (inputs[i] != null) { #if DEBUG try { #endif if (inputs[i].IsActive) { inputs[i].Dispatch(PipeLine); } #if DEBUG } catch (Exception ex) { Debug.Log(ex.StackTrace); } #endif } } if (inputs.Length > 0) { GestureEvent.Dispatch(new List <UserAction>(inputs)); } }
public override void Initial(ModelElement mod) { base.Initial(mod); model = mod; var rect = mod.Context; raw = rect.GetComponent <RawImage>(); var size = model.data.sizeDelta; Width = (int)size.x; Height = (int)size.y; HalfW = Width / 2; HalfH = Height / 2; buffer = new Color[Width * Height]; gesture = EventCallBack.RegEvent <GestureEvent>(rect); gesture.PointerDown = PointDown; gesture.Drag = Drag; gesture.DragEnd = DragEnd; gesture.AutoColor = false; gesture.TowFingerMove = TowFingerMove; Apply(); }
public void DispatchUserAction(Touch[] touches) { DispatchTouch(touches); if (PauseEvent) { return; } PhysicalScale = UISystem.PhysicalScale; if (render != null) { if (render.renderMode == RenderMode.WorldSpace) { PhysicalScale = 1; } } for (int i = 0; i < inputs.Length; i++) { if (inputs[i] != null) { try { inputs[i].PhysicalScale = PhysicalScale; if (inputs[i].IsActive) { inputs[i].Dispatch(PipeLine); } } catch (Exception ex) { Debug.LogError(ex.StackTrace); } } } if (inputs.Length > 0) { GestureEvent.Dispatch(inputs); } }
public void SetEvent(GestureEvent gestureEvent) { this.Event1ComboBox.SelectedValue = gestureEvent.EventPart1; this.Event2ComboBox.SelectedValue = gestureEvent.EventPart2; this.TriggerGestureTextBox.Text = gestureEvent.TriggerGestureName; }
private void HandleGestureEvent(ARFrame arFrame, ARCamera arCamera, float[] projectionMatrix, float[] viewMatrix) { GestureEvent mEvent = mQueuedSingleTaps.Poll().JavaCast <GestureEvent>(); if (mEvent == null) { return; } // Do not perform anything when the object is not tracked. if (arCamera.TrackingState != ARTrackableTrackingState.Tracking) { return; } int eventType = mEvent.GetType(); switch (eventType) { case GestureEvent.GESTURE_EVENT_TYPE_DOUBLETAP: DoWhenEventTypeDoubleTap(viewMatrix, projectionMatrix, mEvent); break; case GestureEvent.GESTURE_EVENT_TYPE_SCROLL: { if (mSelectedObj == null) { break; } ARHitResult hitResult = HitTest4Result(arFrame, arCamera, mEvent.GetEventSecond()); if (hitResult != null) { mSelectedObj.SetAnchor(hitResult.CreateAnchor()); } break; } case GestureEvent.GESTURE_EVENT_TYPE_SINGLETAPCONFIRMED: { // Do not perform anything when an object is selected. if (mSelectedObj != null) { mSelectedObj.SetIsSelected(false); mSelectedObj = null; } MotionEvent tap = mEvent.GetEventFirst(); ARHitResult hitResult = null; hitResult = HitTest4Result(arFrame, arCamera, tap); if (hitResult == null) { break; } DoWhenEventTypeSingleTap(hitResult); break; } default: Log.Info(TAG, "Unknown motion event type, and do nothing."); break; } }
private void DoWhenEventTypeDoubleTap(float[] viewMatrix, float[] projectionMatrix, GestureEvent mEvent) { if (mSelectedObj != null) { mSelectedObj.SetIsSelected(false); mSelectedObj = null; } foreach (VirtualObject obj in mVirtualObjects) { if (mObjectDisplay.HitTest(viewMatrix, projectionMatrix, obj, mEvent.GetEventFirst())) { obj.SetIsSelected(true); mSelectedObj = obj; break; } } }
/*************************************** * gesture recognize ***************************************/ // recognize gesture and dispatch gesture events public override void updateTouchs() { if(!mouseEnable || !_visible || _touchList.Count==0){ return; } foreach(DisplayObject child in _childList){ child.updateTouchs(); } if(_touchList.Count==1){ //if only one finger touch this object, check if the swipe gesture valid Touch soloTouch = (Touch)_touchList[0]; if(soloTouch.phase == TouchPhase.Ended){ if(_swipeCounter>GestureEvent.swipeCountThreshold){ GestureEvent e = new GestureEvent(GestureEvent.SWIPE); e.swipeDirection = _swipeDirection; _swipeDirection = null; this.dispatchEvent(e); } _swipeCounter = 0; }else if(soloTouch.phase == TouchPhase.Moved || soloTouch.phase == TouchPhase.Began){ if(Mathf.Abs(soloTouch.deltaPosition.x)>GestureEvent.swipeDeltaThreshold && (soloTouch.deltaPosition.x>0?GestureEvent.SWIPE_RIGHT:GestureEvent.SWIPE_LEFT)==_swipeDirection){ if(_swipeCounter==0){ _swipeDirection = soloTouch.deltaPosition.x>0?GestureEvent.SWIPE_RIGHT:GestureEvent.SWIPE_LEFT; } _swipeCounter ++; }else{ _swipeCounter = 0; _swipeDirection = null; } }else{ _swipeCounter = 0; _swipeDirection = null; } } if(_touchList.Count==2) { //if only one finger touch this object, check scale, rotate and pan Touch firstTouch = (Touch)_touchList[0]; Touch secondTouch = (Touch)_touchList[1]; //scale float lastDistance = Vector2.Distance(firstTouch.position-firstTouch.deltaPosition,secondTouch.position-secondTouch.deltaPosition); float distance = Vector2.Distance(firstTouch.position,secondTouch.position); float deltaScale = distance/lastDistance; if(Mathf.Abs(deltaScale-1.0f)>0.001){ GestureEvent e = new GestureEvent(GestureEvent.ZOOM); e.deltaScale = deltaScale; this.dispatchEvent(e); } //rotation float lastAng = Mathf.Atan2( (secondTouch.position.y-secondTouch.deltaPosition.y)- (firstTouch.position.y-firstTouch.deltaPosition.y) , (firstTouch.position.x-firstTouch.deltaPosition.x) - (secondTouch.position.x-secondTouch.deltaPosition.x))*Mathf.Rad2Deg; float ang = Mathf.Atan2(secondTouch.position.y - firstTouch.position.y , firstTouch.position.x - secondTouch.position.x)*Mathf.Rad2Deg; float deltaRotation = ang-lastAng; if(Mathf.Abs(deltaRotation)>.01){ GestureEvent e = new GestureEvent(GestureEvent.ROTATE); e.deltaRotation = deltaRotation; this.dispatchEvent(e); } //pan Vector2 avgDeltaPos = (firstTouch.deltaPosition+secondTouch.deltaPosition)/2; if(Mathf.Abs(avgDeltaPos.x)>GestureEvent.panThreshold || Mathf.Abs(avgDeltaPos.y)>GestureEvent.panThreshold){ GestureEvent e = new GestureEvent(GestureEvent.PAN); avgDeltaPos.y = -avgDeltaPos.y; e.deltaPan = avgDeltaPos; this.dispatchEvent(e); } } }
public void SetEvent(GestureEvent gestureEvent) { this.Event1ComboBox.SelectedValue = gestureEvent.EventPart1; this.Event2ComboBox.SelectedValue = gestureEvent.EventPart2; this.TriggerGestureTextBox.Text = gestureEvent.TriggerGestureName; }