void Update() { if (Input.GetMouseButtonDown(0) && !InputUtils.CheckMouseOnUI()) { mIsDown = true; bridgeInfo.GetComponent <Image>().DOFade(0, .8f); } if (Input.GetMouseButton(0) && mIsDown) { if (mLastPos != Vector3.zero) { var delta = RATIO * (Input.mousePosition - mLastPos); mSphericalPos.phi -= delta.x; mSphericalPos.theta += delta.y; if (mSphericalPos.theta < 0.15f * Mathf.PI) { // Debug.LogError("Cs"); mSphericalPos.theta = Mathf.PI * 0.15f; } // Debug.Log(delta + " " + mSphericalPos); } mLastPos = Input.mousePosition; var a = camera.transform.localPosition; var b = SphericalCoordinateSystem.ToCartesian(mSphericalPos) + mCurrentFocus; if (b.y <= mCurrentFocus.y) { b = new Vector3(b.x, mCurrentFocus.y, b.z); } // camera.transform.localPosition = b; camera.transform.localPosition = Vector3.Lerp(a, b, Time.deltaTime * 4); camera.transform.LookAt(mCurrentFocus); } if (Input.GetMouseButtonUp(0)) { mLastPos = Vector3.zero; mIsDown = false; } UpdateUI(); }