Exemple #1
0
        /// <summary>
        /// unity坐标与屏幕坐标的换算
        /// </summary>
        public void SetCorrection()
        {
#if UNITY_EDITOR
            Point p;
            PcImitateInput.GetCursorPos(out p);
            Correction.x = p.X - Input.mousePosition.x;
            Correction.y = p.Y + Input.mousePosition.y;
#else
            Correction.x = 0;
            Correction.y = Screen.height;
#endif
        }
    // Update is called once per frame
    void Update()
    {
        transform.Rotate(Vector3.forward, Time.deltaTime * -10, Space.World);
        float rotate = Mathf.Deg2Rad * (360f - transform.eulerAngles.z);
        float x      = Mathf.Sin(rotate);
        float y      = Mathf.Cos(rotate);

        Debug.Log("unity position : X " + Input.mousePosition.x + ",Y : " + Input.mousePosition.y);
        if (Input.GetMouseButton(0))
        {
            PcImitateInput.GetCursorPos(out p);
            Debug.Log("Screent X : " + Screen.width + "Screen Y" + Screen.height);
            Debug.Log(p);
            Debug.Log("unity position : X " + Input.mousePosition.x + ",Y : " + Input.mousePosition.y);
        }
    }