Ejemplo n.º 1
0
    IEnumerator Start()
    {
        bridgeInfo.GetComponent <Image>().color = new Color(1, 1, 1, 0);
        BackBtn.GetComponent <Image>().color    = new Color(1, 1, 1, 0);
        panelScript.gameObject.SetActive(false);
        mCurrentFocus = pos;
        yield return(CameraActions.FocusAtCoroutine(camera, pos, dir, 80, .5f, t =>
        {
            ShowUI();

            mSphericalPos = SphericalCoordinateSystem.FromCartesian(camera.transform.localPosition - mCurrentFocus);
        }));

        yield return(null);
    }
Ejemplo n.º 2
0
    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();
    }