大神,当我拖动UI时,我不想让我的主摄像机旋转...但我明明使用IsPointerOverGameObject判断了,可是它总是返回false.
private void LateUpdate()
{
if (m_TargetPlayer == null)
return;
transform.position = m_offset + TargetPlayer.position;
// 这里总是返回false
if ( EventSystem.current.IsPointerOverGameObject())
return;
if(Input.GetMouseButton(1))
{
float h = Input.GetAxis("Mouse X");
float v = - Input.GetAxis("Mouse Y");
transform.RotateAround(TargetPlayer.position, TargetPlayer.up, h * m_RotaSpeed);
Vector3 pos = transform.position;
Quaternion rot = transform.rotation;
transform.RotateAround(TargetPlayer.position, transform.right, v * m_RotaSpeed);
float a = transform.eulerAngles.x;
if( a < m_minAngle || a > m_maxAngle )
{
transform.position = pos;
transform.rotation = rot;
}
m_offset = transform.position - TargetPlayer.position;
}
float z = - Input.GetAxis("Mouse ScrollWheel");
if( z < -0.001f || z >= 0.001f )
{
float dis = m_offset.magnitude;
dis = Mathf.Clamp( dis + z * m_ZoomSpeed, m_minZoom, m_maxZoom );
m_offset = dis * m_offset.normalized;
}
}