public void OnDrag(PointerEventData eventData) { if (IsWithItem) { Drag?.Invoke(this, eventData.position); } }
void ContinueInput(Vector3 v) { if (inverted) { begin = v; } else { end = v; } if (Vector3.Distance(begin, end) >= drag_threshold) { dragged = true; } if (interacted) { Interact(v); } if (dragged) { Drag.Invoke(); } }
private void ProcessEvents(Event e) { switch (e.type) { case EventType.MouseDown: if (e.button == 1) { if (MouseClicked != null) { MouseClicked.Invoke(e.mousePosition); } } break; case EventType.MouseDrag: if (e.button == 0) { if (Drag != null) { Drag.Invoke(e.delta); } GUI.changed = true; } break; } }
public override void OnMouseUpdate(Vector2 currentPosition, Vector2 positionDelta, Vector2 rawDelta) { if (IsDragging) { this.accumulatedDragDelta += positionDelta; Drag?.Invoke(currentPosition, this.accumulatedDragDelta); } }
public void OnDrag(PointerEventData eventData) { if (_pointerDownCalled == false) { return; } toDrag.position = _cachedDragPosition + ((Vector2)Input.mousePosition - _cachedMousePosition); Drag?.Invoke(eventData); }
private void OnDrag(EventSystemData Data) { if (!IsDrag_) { return; } IsClick_ = false; Drag?.Invoke(Data.Location); }
public void OnDrag(BaseEventData eventData) { if (!(eventData is PointerEventData)) { return; } PointerEventData pointerData = eventData as PointerEventData; Drag?.Invoke(pointerData.delta); }
public void OnDrag(PointerEventData eventData) { Vector2 pos; // Считаем положение пальца, двигаем стик, получаем вектор перемещения стика относительно центра задней панели. if (RectTransformUtility.ScreenPointToLocalPointInRectangle(_stick.BackPanel, eventData.position, eventData.pressEventCamera, out pos)) { pos.x = (pos.x / _stick.BackPanel.sizeDelta.x); pos.y = (pos.y / _stick.BackPanel.sizeDelta.y); _inputVector = new Vector2(pos.x * 2, pos.y * 2); _inputVector = (_inputVector.magnitude > 1) ? _inputVector.normalized : _inputVector; _stick.Stick.anchoredPosition = new Vector2(_inputVector.x * (_stick.BackPanel.sizeDelta.x / 2), _inputVector.y * (_stick.BackPanel.sizeDelta.y / 2)); } Drag?.Invoke(_inputVector.x, _inputVector.y); }
private void CalculateDrag(Vector3 pos) { if (!Input.GetMouseButton(0)) { return; } var delta = _camera.ScreenToWorldPoint(new Vector3(pos.x, pos.y, _camera.nearClipPlane)) - _camera.ScreenToWorldPoint(new Vector3(_lastPos.x, _lastPos.y, _camera.nearClipPlane)); foreach (var sel in _selected) { sel.OnDrag(delta, pos - _lastPos); } Drag?.Invoke(delta); }
private void Update() { if (EventSystem.current && EventSystem.current.currentSelectedGameObject) { return; } NormalizedDeltaInput = Vector3.zero; NormalizedGroundAlignedDeltaInput = Vector3.zero; var isInput = IsInput; switch (isInput) { case true: var inputPos = InputPos; if (_lastPos.HasValue) // Continue Drag { var delta = inputPos - _lastPos.Value; var normalizedDelta = delta / _screenWidth; Drag?.Invoke(delta); DragNormalized?.Invoke(normalizedDelta); NormalizedDeltaInput = normalizedDelta; NormalizedGroundAlignedDeltaInput = new Vector3(NormalizedDeltaInput.x, 0, NormalizedDeltaInput.y); } else // Start Drag { DragStart?.Invoke(inputPos); } _lastPos = inputPos; break; // Stop Drag case false when _lastPos.HasValue: _lastPos = null; DragEnd?.Invoke(); break; } }
public void OnDrag(PointerEventData eventData) { #if UNITY_EDITOR || !(UNITY_IOS || UNITY_ANDROID) if (eventData.button == PointerEventData.InputButton.Left) { Drag?.Invoke(eventData.delta); } else if (eventData.button == PointerEventData.InputButton.Right) { DoubleDrag?.Invoke(eventData.delta); } #else if (UnityEngine.Input.touchCount == 2) { DoubleDrag?.Invoke(eventData.delta); Pinch(); } else if (UnityEngine.Input.touchCount == 1) { Drag?.Invoke(eventData.delta); } #endif }
public void OnDrag(PointerEventData eventData) { Drag?.Invoke(eventData.position); }
public ButtonForm() { SetImage(new VTex2D("Data\\UI\\Skin\\but_normal.png", LoadMethod.Single, true)); Col = NormCol; void DrawFunc() { VPen.BlendMod = VBlend.Alpha; DrawForm(CoreTex); DrawText(Text, W / 2 - UI.Font.Width(Text) / 2, H / 2 - UI.Font.Height() / 2); } void MouseEnterFunc() { if (Pressed == false) { Col = OverCol; } Over = true; } void MouseLeaveFunc() { if (Pressed == false) { Col = NormCol; } Over = false; } void MouseMoveFunc(int x, int y, int dx, int dy) { if (Pressed) { Drag?.Invoke(dx, dy); } } void MouseDownFunc(int b) { Col = PressCol; Pressed = true; } void MouseUpFunc(int b) { if (Over) { Col = OverCol; } else { Col = NormCol; } Pressed = false; Click?.Invoke(b); } Draw = DrawFunc; MouseEnter = MouseEnterFunc; MouseLeave = MouseLeaveFunc; MouseMove = MouseMoveFunc; MouseDown = MouseDownFunc; MouseUp = MouseUpFunc; }
/// <summary> /// Raises the <see cref="E:Drag"/> event. /// </summary> /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param> protected virtual void OnDrag(MarkerEventArgs e) { Drag?.Invoke(this, e); }
public override void OnDrag(PointerEventData eventData) { Drag?.Invoke(eventData.delta); }
internal void SendDrag(AnnotationDragState state) { Drag?.Invoke(this, new AnnotationDragEventArgs(state)); }
/// <summary> /// Raises the Drag event. /// </summary> protected void OnDrag(EventArgs <Point> e) => Drag?.Invoke(this, e);