internal static void Init() { PreUpdate(); LastPosition = Position; App.platform.OnMouseButtonDown += id => { down[id] = true; pressed[id] = true; OnPress?.Invoke((MouseButton)id); }; App.platform.OnMouseButtonUp += id => { down[id] = false; released[id] = true; OnRelease?.Invoke((MouseButton)id); }; App.platform.OnMouseScroll += (x, y) => { Scroll += new Point2((int)(x / Screen.PixelSize), (int)(y / Screen.PixelSize)); OnScroll?.Invoke(); }; }
protected void InvokeOnRelease(T item) { if (OnRelease != null) { OnRelease.Invoke(item); } }
private void HandleInput() { if (Input.GetMouseButtonDown(0)) { isGrappling = true; } if (Input.GetMouseButton(0)) { if (isGrappling) { isGrappling = false; var clickResult = OnClicked?.Invoke(player.transform.position); if (clickResult.HasValue) { var joint = clickResult.Value.Item1; joint.connectedBody = player; OnAttach?.Invoke(joint.transform.position); TravelAmount = clickResult.Value.Item2 + 1; OnScore?.Invoke(TravelAmount); } } } if (Input.GetMouseButtonUp(0)) { OnRelease?.Invoke(); } }
/// <summary> /// 释放 /// </summary> public virtual void OnDistanceRelesae(DistanceInteraction distanceInteraction) { if (OnRelease != null) { OnRelease.Invoke(distanceInteraction); } }
public void Update(GameTime gameTime, KeyboardState keyboardState, MouseState mouseState, MouseState prevMouseState) { if (isBeingClicked) { var progress = Math.Clamp((mouseState.Position.X - RectOnScreen.Left) / Size.X, 0, 1); var value = Min + (Max - Min) * progress; if (mouseState.LeftButton == ButtonState.Released) { OnRelease?.Invoke(value); isBeingClicked = false; } else if (progress != CurrentProgress) { OnChange?.Invoke(value); } CurrentProgress = progress; CurrentValue = value; } if (mouseState.LeftButton == ButtonState.Pressed && RectOnScreen.Contains(mouseState.Position)) { if (prevMouseState.LeftButton == ButtonState.Released) { isBeingClicked = true; } } }
public override void Init() { GetButton(ModifierButton).OnRelease += () => { if (Blocked || !Pressed) { return; } Pressed = false; OnRelease?.Invoke(); }; GetButton(Button).OnPress += () => { if (Blocked || !GetButton(ModifierButton).isActive) { return; } Pressed = true; OnPress?.Invoke(); }; GetButton(Button).OnRelease += () => { if (Blocked || !Pressed) { return; } if (!GetButton(ModifierButton).isActive) { return; } Pressed = false; OnRelease?.Invoke(); }; }
/// <summary> /// 释放扩展 /// </summary> /// <param name="extend">扩展实现</param> private void InternalRelease(TInterface extend) { OnRelease?.Invoke(extend); var dispose = extend as IDisposable; dispose?.Dispose(); }
private void CheckSwipeEditor() { if (Input.GetMouseButtonDown(0)) //pressed { startPos = Input.mousePosition; holdTime = 0; } else if (Input.GetMouseButton(0)) //held { holdTime += Time.deltaTime; } else if (Input.GetMouseButtonUp(0)) //de-pressed { Vector2 endPos = Input.mousePosition; Vector2 deltaPos = endPos - startPos; //Debug.Log("" + (deltaPos.magnitude > swipeDistanceThreshold) + " and " + (holdTime < swipeTimeThreshold)); if (deltaPos.magnitude > swipeDistanceThreshold && holdTime < swipeTimeThreshold) { OnSwipe?.Invoke(deltaPos, endPos); } else { OnRelease?.Invoke(); } } }
public virtual void Consume(TouchInfo ti) { if (ti.TouchState == TouchState.Pressed) { mouseOver = true; if (OnPressed != null) { OnPressed.Fire(ti); } } else if (ti.TouchState == TouchState.Released) { mouseOver = false; if (ti.Delta.Length2() < 2500f / 480 / 480) { if (OnRelease != null) { OnRelease.Fire(ti); } } } else if (ti.TouchState == TouchState.Moved) { mouseOver = true; OnMoved.Fire(ti); } }
public virtual void Init() { var otherButtons = BUTTONS.Where(button => button != Button).ToList(); otherButtons.ForEach(button => GetButton(button).OnPress += () => { Pressed = false; }); GetButton(Button).OnPress += () => { if (Blocked) { return; } if (otherButtons.Any(id => GetButton(id).isActive)) { return; } Pressed = true; OnPress?.Invoke(); }; GetButton(Button).OnRelease += () => { if (Blocked || !Pressed) { return; } if (otherButtons.Any(id => GetButton(id).isActive)) { return; } Pressed = false; OnRelease?.Invoke(); }; }
private void Update() { if (IsTripleTouch) { OnTripleTouch?.Invoke(); return; } if (StaticUtilities.IsPointerOverUIObject()) { return; } var inputPosition = Input.mousePosition; if (IsPressed) { OnPress?.Invoke(inputPosition); } if (IsDrag) { OnDrag?.Invoke(inputPosition); } if (IsReleased) { OnRelease?.Invoke(); } }
// Update is called once per frame void Update() { if (Input.touchCount > 0) { _touch = Input.GetTouch(0); _touchTimer += Time.deltaTime; switch (_touch.phase) { case TouchPhase.Ended: if (_touch.tapCount >= 2) { StopAllCoroutines(); if (OnDoubleClick != null) { OnDoubleClick.Invoke(_touch); Debug.Log("Working"); } } else if (_touchTimer < LongPressThreshold) { StartCoroutine(CheckSingleClick()); } else if (_touchTimer > LongPressThreshold) { StopAllCoroutines(); OnRelease.Invoke(_touch); } break; case TouchPhase.Moved: if (_touchTimer > LongPressThreshold) { if (OnLongPressing != null) { OnLongPressing.Invoke(_touch); } } break; case TouchPhase.Stationary: if (_touchTimer > LongPressThreshold) { if (OnLongPressing != null) { OnLongPressing.Invoke(_touch); } } break; default: break; } } else { _touchTimer = 0; } }
private void _timer_Tick(object sender, EventArgs e) { var dt = DateTime.Now - _lastClick; if (dt.TotalMilliseconds > Interval) { OnRelease?.Execute(null); _timer.Stop(); } }
private bool Release(int touchId, Vector2 position) { if (Pressed && TouchId == touchId) { OnRelease?.Invoke(position); Pressed = false; return(true); } return(false); }
public Button(GameObject owner, Rectangle bounds, SpriteFont fnt, string label, Color clr, OnRelease releaseAction, string name = null) : base(owner, name) { relativeBounds = bounds; idleColor = clr; texture = Graphics.TextureFromURL(@"https://megachuck64.github.io/assets/defaultButton.png"); text = label; drawLayer = 0.1f; font = fnt; startWindowSize = owner.game.Window.ClientBounds.Size.ToVector2(); onRelease = releaseAction; }
public virtual void Release() { if (currentObject == null) { return; } OnRelease.Invoke(currentObject.gameObject); currentObject.Release(this); currentObject = null; }
public void Init() { CaveInputBinding.Flystick(Instance).GetButton(Button).OnPress += () => { Pressed = true; OnPress?.Invoke(); }; CaveInputBinding.Flystick(Instance).GetButton(Button).OnRelease += () => { Pressed = false; OnRelease?.Invoke(); }; }
public override void OnPointerUp(PointerEventData eventData) { if (joystickType != JoystickType.Fixed) { background.gameObject.SetActive(false); } OnRelease?.Invoke(eventData); base.OnPointerUp(eventData); }
private void _buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e) { if (e.Edge == GpioPinEdge.FallingEdge) { OnPress?.Invoke(sender, e); } else { OnRelease?.Invoke(sender, e); } }
public Action(KeyCode key, string name, OnTrigger onTrigger = null, OnHold onHold = null, OnRelease onRelease = null) { Key = key; Name = name; OnTriggerMethod = onTrigger; OnHoldMethod = onHold; OnReleaseMethod = onRelease; }
public void PointerUp() { if (lastPointerDownTime != null) { OnClick?.Invoke(); lastPointerDownTime = null; } else { OnRelease?.Invoke(); } }
public void OnPoolRelease() { if (lifecycleHandlers != null) { for (var i = 0; i < lifecycleHandlers.Length; i++) { var handler = lifecycleHandlers[i]; handler.OnPoolRelease(); } } OnRelease?.Invoke(); }
public void CheckForInput() { if (ButtonType == ButtonType.Mouse ? Input.GetMouseButtonDown((int)MouseButton) : Input.GetKeyDown(KeyboardButton)) { Pressed = true; OnPress?.Invoke(); } if (ButtonType == ButtonType.Mouse ? Input.GetMouseButtonUp((int)MouseButton) : Input.GetKeyUp(KeyboardButton)) { Pressed = false; OnRelease?.Invoke(); } }
/// <summary> /// Release rocker. /// </summary> protected virtual void OnMouseUp() { if (!isEnabled) { return; } if (revertSpeed > 0) { InvokeRepeating("Revert", 0, Time.fixedDeltaTime); } OnRelease.Invoke(); }
private void _ReleaseSlider() { Cursor.Margin = InitialCursorMargin; DynamicBar.X2 = DynamicBar.X1; CurrentValueText.Text = ""; OnRelease?.Invoke(this, new OnReleaseArgs() { Value = (int)CurrentValue }); CurrentValue = 0; ToolTipFlyout.Hide(); }
private void Update() { if (Input.GetMouseButtonUp(0) && IsPressing) // "OnMouseUp()" is unreliable. { if (resetOnRelease) { transform.position = startWorldPosition; } OnRelease.Invoke(); IsPressing = false; } }
private void OnMouseButton(MouseButton button, InputAction action, KeyModifiers mods) { if (button == MouseButton.Left && Hovered) { if (action == InputAction.Press) { OnClick?.Invoke(this, null); } else if (action == InputAction.Release) { OnRelease?.Invoke(this, null); } } }
public void Release(Vector2 input) { if (joint != null) { joint.connectedBody = null; joint.enabled = false; if (input == Vector2.zero) { motor.velocity = Vector3.zero; } OnRelease?.Invoke(); Destroy(ActiveGrab, .1f); } }
public void CleanUp() { filename = null; #if UNITY_EDITOR tag = ""; #endif if (OnRelease != null) { foreach (Delegate d in OnRelease.GetInvocationList()) { OnRelease -= (ReleaseEvent)d; } } }
public void Release(VRHand hand) { if (Holder != hand) { return; } TrackHolder(Holder.position, Holder.rotation); rb.velocity = SmoothVelocity; rb.angularVelocity = SmoothSpin; OnRelease.Invoke(hand.gameObject); Holder = null; }