拖动鼠标水平旋转物体查看

版权声明:转载请注明,谢谢 https://blog.csdn.net/qq_38655924/article/details/84068579
 private Vector3 startPoint;
    private Vector3 endPoint;
    private int disToAngle = 5;
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            startPoint = Input.mousePosition;
        }
        if (Input.GetMouseButton(0))
        {
            endPoint = Input.mousePosition;
        }
        float dx = endPoint.x - startPoint.x;
        float angle = dx / disToAngle;
        this.transform.localEulerAngles = new Vector3(0, angle, 0);

    }

猜你喜欢

转载自blog.csdn.net/qq_38655924/article/details/84068579