Пример #1
0
        /// <summary>
        /// Old-style mouse events used prior to the new event system of 4.2.
        /// </summary>

        static void SendEvents(int i, HitInfo hit)
        {
            // Handle MouseDown, MouseDrag, MouseUp
            bool mouseDownThisFrame = Input.GetMouseButtonDown(0);
            bool mousePressed       = Input.GetMouseButton(0);

            if (mouseDownThisFrame)
            {
                if (hit)
                {
                    m_MouseDownHit[i] = hit;
                    m_MouseDownHit[i].SendMessage("OnMouseDown");
                }
            }
            else if (!mousePressed)
            {
                if (m_MouseDownHit[i])
                {
                    // For button like behavior only fire this event if same as on MouseDown
                    if (HitInfo.Compare(hit, m_MouseDownHit[i]))
                    {
                        m_MouseDownHit[i].SendMessage("OnMouseUpAsButton");
                    }

                    // For backwards compatibility we keep the event name OnMouseUp
                    m_MouseDownHit[i].SendMessage("OnMouseUp");
                    m_MouseDownHit[i] = new HitInfo();
                }
            }
            else if (m_MouseDownHit[i])
            {
                m_MouseDownHit[i].SendMessage("OnMouseDrag");
            }


            // Handle MouseOver, MouseEnter, MouseExit
            if (HitInfo.Compare(hit, m_LastHit[i]))
            {
                if (hit)
                {
                    hit.SendMessage("OnMouseOver");
                }
            }
            else
            {
                if (m_LastHit[i])
                {
                    m_LastHit[i].SendMessage("OnMouseExit");
                }

                if (hit)
                {
                    hit.SendMessage("OnMouseEnter");
                    hit.SendMessage("OnMouseOver");
                }
            }
            m_LastHit[i] = hit;
        }
Пример #2
0
        private static void SendEvents(int i, HitInfo hit)
        {
            bool mouseButtonDown = Input.GetMouseButtonDown(0);
            bool mouseButton     = Input.GetMouseButton(0);

            if (mouseButtonDown)
            {
                if (hit != 0)
                {
                    m_MouseDownHit[i] = hit;
                    m_MouseDownHit[i].SendMessage("OnMouseDown");
                }
            }
            else if (!mouseButton)
            {
                if (m_MouseDownHit[i] != 0)
                {
                    if (HitInfo.Compare(hit, m_MouseDownHit[i]))
                    {
                        m_MouseDownHit[i].SendMessage("OnMouseUpAsButton");
                    }
                    m_MouseDownHit[i].SendMessage("OnMouseUp");
                    m_MouseDownHit[i] = new HitInfo();
                }
            }
            else if (m_MouseDownHit[i] != 0)
            {
                m_MouseDownHit[i].SendMessage("OnMouseDrag");
            }
            if (HitInfo.Compare(hit, m_LastHit[i]))
            {
                if (hit != 0)
                {
                    hit.SendMessage("OnMouseOver");
                }
            }
            else
            {
                if (m_LastHit[i] != 0)
                {
                    m_LastHit[i].SendMessage("OnMouseExit");
                }
                if (hit != 0)
                {
                    hit.SendMessage("OnMouseEnter");
                    hit.SendMessage("OnMouseOver");
                }
            }
            m_LastHit[i] = hit;
        }