public override void OnCancel() { if (dragableBrick == null) { return; } OnCancelMove?.Invoke(); //reset position and rotation dragableBrick.transform.position = oldPosition; dragableBrick.transform.rotation = oldRotation; //rebuild brick joints var agaqBrick = dragableBrick.GetComponent <AgaQBrick>(); if (agaqBrick != null) { agaqBrick.RebuildJoints(); } EndDragging(); OnModelChange?.Invoke(); }
bool LMBRelesed; //is LFM released after start drag #region Event handlers public override void OnUpdate() { if (isDragging) { HandleRotationKeys(dragableBrick); MoveToCursor(dragableBrick, Input.mousePosition); OnModelChange?.Invoke(); if (!LMBRelesed && Input.GetMouseButtonUp((int)MouseButton.LeftMouse)) { LMBRelesed = true; } else if (LMBRelesed && Input.GetMouseButtonDown((int)MouseButton.LeftMouse) && CameraController.instance.IsInsideWorkArea(Input.mousePosition)) { OnEndDrag(dragableBrick, null); } } else if (isPointJoining) { MovePointToPoint(); if (Input.GetMouseButtonUp(0)) { isPointJoining = false; if (historyNodes[0].oldPosition != pointJoinBrick.transform.position) { RegisterHistory(); } } } else if (Input.GetKey(KeyCode.V)) { HighlightPoint(); } else if (Input.GetKeyUp(KeyCode.V)) { MeasureToolVisualizer.instance.ResetHighlight(); OnCancel(); } }