三维物体跟随鼠标移动

 //上下 x(-45,15) 
    //左右 y(-60,60) 
    private float maxYRotation = 120;
    private float minYRotation = 0;
    private float maxXRotation = 60;
    private float minXRotation = 0;
 void Update()
    {
       //计算出鼠标在屏幕上的位置
            float xPosPrecent = Input.mousePosition.x / Screen.width;
            float yPosPrecent = Input.mousePosition.y / Screen.height;

            //Mathf.Clamp 限制value的值在min和max之间 如果value小于min,返回min。如果value大于max,返回max,否则返回value 
            float xAngele = -Mathf.Clamp(yPosPrecent * maxXRotation, minXRotation, maxXRotation) + 15;
            float yAngele = Mathf.Clamp(xPosPrecent * maxYRotation, minYRotation, maxYRotation) - 60;

            transform.eulerAngles = new Vector3(xAngele, yAngele, 0);
        }
      
    }

 

三维物体跟随鼠标移动

上一篇:[hdu2460]network(依次连边并询问图中割边数量) tarjan边双联通分量+lca


下一篇:iPhone/iPad/Android UI尺寸规范