Ejemplo n.º 1
0
    void Update()
    {
        if (Input.GetMouseButtonDown(1) && EventSystem.current.IsPointerOverGameObject() == false)
        {
            dragging = true;
        }

        if (dragging)
        {
            if (Input.GetMouseButton(1))
            {
                Vector3 currentPos = transform.position;
                float   xAxis      = Input.GetAxis("Mouse X");
                float   zAxis      = Input.GetAxis("Mouse Y");
                if (zoomHandler != null)
                {
                    currentPos.x -= xAxis * (speed * zoomHandler.distanceScale);
                    currentPos.z -= zAxis * (speed * zoomHandler.distanceScale);
                }
                if (zAxis != 0 || xAxis != 0)
                {
                    if (_motor != null)
                    {
                        _motor.SetFreePosition(currentPos);
                    }
                }
            }
            else
            {
                dragging = false;
            }
        }
    }
Ejemplo n.º 2
0
    private void Update()
    {
        Vector3 target = transform.position;

        if (Input.mousePosition.y >= Screen.height - borderWeight && Input.mousePosition.y <= Screen.height)
        {
            target    = target + (Vector3.forward * speed);
            isPanning = true;
        }
        else if (Input.mousePosition.y <= borderWeight && Input.mousePosition.y >= 0)
        {
            target    = target + (Vector3.back * speed);
            isPanning = true;
        }
        if (Input.mousePosition.x >= Screen.width - borderWeight && Input.mousePosition.x <= Screen.width)
        {
            target    = target + (Vector3.right * speed);
            isPanning = true;
        }
        else if (Input.mousePosition.x <= borderWeight && Input.mousePosition.x >= 0)
        {
            target    = target + (Vector3.left * speed);
            isPanning = true;
        }
        if (target == transform.position)
        {
            isPanning = false;
        }
        if (isPanning)
        {
            if (_motor != null)
            {
                _motor.SetFreePosition(target);
            }
        }
    }