public void ProcessPointerCapture(int pointerId)
        {
            if (m_PointerCapture[pointerId] == m_PendingPointerCapture[pointerId])
            {
                return;
            }

            if (m_PointerCapture[pointerId] != null)
            {
                using (var e =
                           PointerCaptureOutEvent.GetPooled(m_PointerCapture[pointerId], m_PendingPointerCapture[pointerId], pointerId))
                {
                    m_PointerCapture[pointerId].SendEvent(e);
                }

                if (pointerId == PointerId.mousePointerId)
                {
                    using (var e =
                               MouseCaptureOutEvent.GetPooled(m_PointerCapture[pointerId], m_PendingPointerCapture[pointerId], pointerId))
                    {
                        m_PointerCapture[pointerId].SendEvent(e);
                    }
                }
            }

            if (m_PendingPointerCapture[pointerId] != null)
            {
                using (var e =
                           PointerCaptureEvent.GetPooled(m_PendingPointerCapture[pointerId], m_PointerCapture[pointerId], pointerId))
                {
                    m_PendingPointerCapture[pointerId].SendEvent(e);
                }

                if (pointerId == PointerId.mousePointerId)
                {
                    using (var e =
                               MouseCaptureEvent.GetPooled(m_PendingPointerCapture[pointerId], m_PointerCapture[pointerId], pointerId))
                    {
                        m_PendingPointerCapture[pointerId].SendEvent(e);
                    }
                }
            }

            m_PointerCapture[pointerId] = m_PendingPointerCapture[pointerId];
        }
        public void ProcessPointerCapture(int pointerId)
        {
            bool flag = this.m_PointerCapture[pointerId] == this.m_PendingPointerCapture[pointerId];

            if (!flag)
            {
                bool flag2 = this.m_PointerCapture[pointerId] != null;
                if (flag2)
                {
                    using (PointerCaptureOutEvent pooled = PointerCaptureEventBase <PointerCaptureOutEvent> .GetPooled(this.m_PointerCapture[pointerId], this.m_PendingPointerCapture[pointerId], pointerId))
                    {
                        this.m_PointerCapture[pointerId].SendEvent(pooled);
                    }
                    bool flag3 = pointerId == PointerId.mousePointerId;
                    if (flag3)
                    {
                        using (MouseCaptureOutEvent pooled2 = PointerCaptureEventBase <MouseCaptureOutEvent> .GetPooled(this.m_PointerCapture[pointerId], this.m_PendingPointerCapture[pointerId], pointerId))
                        {
                            this.m_PointerCapture[pointerId].SendEvent(pooled2);
                        }
                    }
                }
                bool flag4 = this.m_PendingPointerCapture[pointerId] != null;
                if (flag4)
                {
                    using (PointerCaptureEvent pooled3 = PointerCaptureEventBase <PointerCaptureEvent> .GetPooled(this.m_PendingPointerCapture[pointerId], this.m_PointerCapture[pointerId], pointerId))
                    {
                        this.m_PendingPointerCapture[pointerId].SendEvent(pooled3);
                    }
                    bool flag5 = pointerId == PointerId.mousePointerId;
                    if (flag5)
                    {
                        using (MouseCaptureEvent pooled4 = PointerCaptureEventBase <MouseCaptureEvent> .GetPooled(this.m_PendingPointerCapture[pointerId], this.m_PointerCapture[pointerId], pointerId))
                        {
                            this.m_PendingPointerCapture[pointerId].SendEvent(pooled4);
                        }
                    }
                }
                this.m_PointerCapture[pointerId] = this.m_PendingPointerCapture[pointerId];
            }
        }
Пример #3
0
        public static void CaptureMouse(this IEventHandler handler)
        {
            if (mouseCapture == handler)
            {
                return;
            }

            if (handler == null)
            {
                ReleaseMouse();
                return;
            }

            if (GUIUtility.hotControl != 0)
            {
                Debug.Log("Should not be capturing when there is a hotcontrol");
                return;
            }

            // TODO: assign a reserved control id to hotControl so that repaint events in OnGUI() have their hotcontrol check behave normally

            IEventHandler currentMouseCapture = mouseCapture;

            mouseCapture = handler;

            if (currentMouseCapture != null)
            {
                using (MouseCaptureOutEvent releaseEvent = MouseCaptureOutEvent.GetPooled(currentMouseCapture, mouseCapture))
                {
                    currentMouseCapture.SendEvent(releaseEvent);
                }
            }

            using (MouseCaptureEvent captureEvent = MouseCaptureEvent.GetPooled(mouseCapture, currentMouseCapture))
            {
                mouseCapture.SendEvent(captureEvent);
            }
        }