Ejemplo n.º 1
0
        public void HandlePing()
        {
            if (!isPinging)
            {
                return;
            }

            float num1 = m_ZoomTime + m_WaitTime + m_FadeOutTime;
            float num2 = Time.realtimeSinceStartup - m_TimeStart;

            if (num2 >= 0f && num2 < num1)
            {
                Color     color   = GUI.color;
                Matrix4x4 matrix1 = GUI.matrix;
                if (num2 < m_ZoomTime)
                {
                    float     num3    = m_ZoomTime / 2f;
                    float     num4    = (float)((m_PeakScale - 1.0) * ((m_ZoomTime - Mathf.Abs(num3 - num2)) / num3 - 1.0) + 1.0);
                    Matrix4x4 matrix2 = GUI.matrix;
                    Vector2   vector2 = GUIClipWrap.Unclip(m_ContentRect.xMax >= m_AvailableWidth ? new Vector2(m_AvailableWidth, m_ContentRect.center.y) : m_ContentRect.center);
                    GUI.matrix = Matrix4x4.TRS(vector2, Quaternion.identity, new Vector3(num4, num4, 1f)) * Matrix4x4.TRS(-vector2, Quaternion.identity, Vector3.one) * matrix2;
                }
                else if (num2 > m_ZoomTime + m_WaitTime)
                {
                    float num3 = (num1 - num2) / m_FadeOutTime;
                    GUI.color = new Color(color.r, color.g, color.b, color.a * num3);
                }
                if (m_ContentDraw != null && Event.current.type == EventType.Repaint)
                {
                    Rect position = m_ContentRect;
                    position.x -= m_PingStyle.padding.left;
                    position.y -= m_PingStyle.padding.top;
                    m_PingStyle.Draw(position, GUIContent.none, false, false, false, false);
                    m_ContentDraw(m_ContentRect);
                }
                GUI.matrix = matrix1;
                GUI.color  = color;
            }
            else
            {
                m_TimeStart = -1f;
            }
        }
        internal static Vector2 MouseDeltaReader(Rect position, bool activated)
        {
            int   controlId = GUIUtility.GetControlID("MouseDeltaReader".GetHashCode(), FocusType.Passive, position);
            Event current   = Event.current;

            switch (current.GetTypeForControl(controlId))
            {
            case EventType.MouseDown:
                if (activated && GUIUtility.hotControl == 0 && (position.Contains(current.mousePosition) && current.button == 0))
                {
                    GUIUtility.hotControl      = controlId;
                    GUIUtility.keyboardControl = 0;
                    s_MouseDeltaReaderLastPos  = GUIClipWrap.Unclip(current.mousePosition);
                    current.Use();
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == controlId && current.button == 0)
                {
                    GUIUtility.hotControl = 0;
                    current.Use();
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlId)
                {
                    Vector2 vector2_1 = GUIClipWrap.Unclip(current.mousePosition);
                    Vector2 vector2_2 = vector2_1 - s_MouseDeltaReaderLastPos;
                    s_MouseDeltaReaderLastPos = vector2_1;
                    current.Use();
                    return(vector2_2);
                }
                break;
            }
            return(Vector2.zero);
        }