Exemplo n.º 1
0
        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();
        }
    public void ChangeModel()
    {
        //remove the old model
        foreach (Transform child in _modelParent)
        {
            GameObject.Destroy(child.gameObject);
        }

        //display the new one
        GameObject selectedModel = models[_modelDropdown.value];
        GameObject newModel      = Instantiate(selectedModel, _modelParent);

        onModelChange.Invoke(newModel);
    }
Exemplo n.º 3
0
        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();
            }
        }