Ejemplo n.º 1
0
        void LateUpdate()
        {
            if (!target)
            {
                gameObject.SetActive(false);
                return;
            }
            if (autoScale)
            {
                transform.localScale =
                    Vector3.one * (Vector3.Distance(CameraModeChanger.Instance.ActiveCamera.transform.position, transform.position) * autoScaleFactor) / 15;
            }

            if (previousType != type || previousAxes != axes)
            {
                Clear();
                CreateHandles();
                previousType = type;
                previousAxes = axes;
            }

            HandleBase axis = GetAxis();

            HandleOverEffect(axis);

            if (Input.GetMouseButton(0) && draggingAxis != null)
            {
                draggingAxis.Interact(previousPosition);
                movedHandle.Invoke();
            }

            if (Input.GetMouseButtonDown(0) && axis != null)
            {
                draggingAxis = axis;
                draggingAxis.StartInteraction();

                TakeInteractionPriority();
            }

            if (Input.GetMouseButtonUp(0) && draggingAxis != null)
            {
                Debug.Log("End interaction");
                draggingAxis.EndInteraction();
                draggingAxis = null;

                StopInteraction();
            }

            previousPosition = Mouse.current.position.ReadValue();

            transform.position = target.transform.position;
            if (space == HandleSpace.LOCAL || type == HandleType.SCALE)
            {
                transform.rotation = target.transform.rotation;
            }
            else
            {
                transform.rotation = Quaternion.identity;
            }
        }
Ejemplo n.º 2
0
        void Update()
        {
            if (autoScale)
            {
                transform.localScale =
                    Vector3.one * (Vector3.Distance(handleCamera.transform.position, transform.position) * autoScaleFactor) / 15;
            }

            if (_previousType != type || _previousAxes != axes)
            {
                Clear();
                CreateHandles();
                _previousType = type;
                _previousAxes = axes;
            }

            HandleBase handle   = null;
            Vector3    hitPoint = Vector3.zero;

            GetHandle(ref handle, ref hitPoint);

            HandleOverEffect(handle);

            if (Input.GetMouseButton(0) && _draggingHandle != null)
            {
                _draggingHandle.Interact(_previousMousePosition);
            }

            if (Input.GetMouseButtonDown(0) && handle != null)
            {
                _draggingHandle = handle;
                _draggingHandle.StartInteraction(hitPoint);
            }

            if (Input.GetMouseButtonUp(0) && _draggingHandle != null)
            {
                _draggingHandle.EndInteraction();
                _draggingHandle = null;
            }

            _previousMousePosition = Input.mousePosition;

            transform.position = target.transform.position;
            if (space == HandleSpace.LOCAL || type == HandleType.SCALE)
            {
                transform.rotation = target.transform.rotation;
            }
            else
            {
                transform.rotation = Quaternion.identity;
            }
        }