U3D判断触摸拖动的方向

来源:互联网 发布:淘宝手淘搜索提升 编辑:程序博客网 时间:2024/06/06 10:39
    Vector3 m_startPos;    Vector3 m_endPos;    bool m_down = false;    void FingerSwipe()    {        if (Application.platform == RuntimePlatform.WindowsEditor)        {            if (Input.GetMouseButtonDown(0))            {                if (m_down == false)                {                    m_down = true;                    m_startPos = Input.mousePosition;                }            }            else if (Input.GetMouseButtonUp(0))            {                m_down = false;                m_endPos = Input.mousePosition;                if (m_startPos.x - m_endPos.x > 10.0f)                {                    Debug.Log("left");                }                else if (m_endPos.x - m_startPos.x > 10.0f)                {                    Debug.Log("right");                }                m_startPos = m_endPos;            }        }    }

FingerSwipe放到update中

0 0
原创粉丝点击