Пример #1
0
        private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int threadIdx, float timeOffset, bool ghost, bool includeSubSamples)
        {
            float  num1 = !ghost ? 7f : 21f;
            string selectedPropertyPath = ProfilerDriver.selectedPropertyPath;
            Color  color1       = GUI.color;
            Color  contentColor = GUI.contentColor;

            Color[] colors = ProfilerColors.colors;
            bool    flag1  = false;
            float   x1     = -1f;
            float   x2     = -1f;
            float   y1     = -1f;
            int     size   = 0;
            float   y2     = -1f;
            string  str    = (string)null;
            float   num2   = !includeSubSamples ? r.height : 16f;
            float   num3   = !includeSubSamples ? 0.0f : 1f;
            float   height = num2 - 2f * num3;

            r.height -= num3;
            GUI.BeginGroup(r);
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Rect& local = @r;
            float num4  = 0.0f;

            r.y = num4;
            double num5 = (double)num4;

            // ISSUE: explicit reference operation
            (^ local).x = (float)num5;
            bool  flag2     = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown;
            bool  flag3     = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown;
            Rect  shownArea = this.m_TimeArea.shownArea;
            float rectWidthDivShownWidth = r.width / shownArea.width;
            float x3            = r.x;
            float x4            = shownArea.x;
            bool  enterChildren = true;

            while (iter.Next(enterChildren))
            {
                enterChildren = includeSubSamples;
                float time        = iter.startTimeMS + timeOffset;
                float durationMs  = iter.durationMS;
                float num6        = Mathf.Max(durationMs, 0.0003f);
                float pixelCached = ProfilerTimelineGUI.TimeToPixelCached(time, rectWidthDivShownWidth, x4, x3);
                float num7        = ProfilerTimelineGUI.TimeToPixelCached(time + num6, rectWidthDivShownWidth, x4, x3) - 1f;
                float width       = num7 - pixelCached;
                if ((double)pixelCached > (double)r.x + (double)r.width || (double)num7 < (double)r.x)
                {
                    enterChildren = false;
                }
                else
                {
                    float num8 = (float)(iter.depth - 1);
                    float y3   = r.y + num8 * num2;
                    if (flag1)
                    {
                        bool flag4 = false;
                        if ((double)width >= (double)num1)
                        {
                            flag4 = true;
                        }
                        if ((double)y1 != (double)y3)
                        {
                            flag4 = true;
                        }
                        if ((double)pixelCached - (double)x2 > 6.0)
                        {
                            flag4 = true;
                        }
                        if (flag4)
                        {
                            this.DrawSmallGroup(x1, x2, y1, height, size);
                            flag1 = false;
                        }
                    }
                    if ((double)width < (double)num1)
                    {
                        enterChildren = false;
                        if (!flag1)
                        {
                            flag1 = true;
                            y1    = y3;
                            x1    = pixelCached;
                            size  = 0;
                        }
                        x2 = num7;
                        ++size;
                    }
                    else
                    {
                        int    id    = iter.id;
                        string path  = iter.path;
                        bool   flag4 = path == selectedPropertyPath && !ghost;
                        if (this.m_SelectedID >= 0)
                        {
                            flag4 &= id == this.m_SelectedID;
                        }
                        bool  flag5  = flag4 & threadIdx == this.m_SelectedThread;
                        Color white  = Color.white;
                        Color color2 = colors[iter.group % colors.Length];
                        color2.a = !flag5 ? 0.75f : 1f;
                        if (ghost)
                        {
                            color2.a = 0.4f;
                            white.a  = 0.5f;
                        }
                        string text = iter.name;
                        if (flag5)
                        {
                            str = text;
                            this.m_SelectedTime = time;
                            this.m_SelectedDur  = durationMs;
                            y2 = y3 + num2;
                        }
                        if ((double)width < 20.0 || !includeSubSamples)
                        {
                            text = string.Empty;
                        }
                        else
                        {
                            if ((double)width < 50.0 && !flag5)
                            {
                                white.a *= (float)(((double)width - 20.0) / 30.0);
                            }
                            if ((double)width > 200.0)
                            {
                                text += string.Format(" ({0:f2}ms)", (object)durationMs);
                            }
                        }
                        GUI.color        = color2;
                        GUI.contentColor = white;
                        Rect position = new Rect(pixelCached, y3, width, height);
                        GUI.Label(position, text, ProfilerTimelineGUI.styles.bar);
                        if ((flag2 || flag3) && position.Contains(Event.current.mousePosition))
                        {
                            this.m_Window.SetSelectedPropertyPath(path);
                            this.m_SelectedThread = threadIdx;
                            this.m_SelectedID     = id;
                            UnityEngine.Object gameObject = EditorUtility.InstanceIDToObject(iter.instanceId);
                            if (gameObject is Component)
                            {
                                gameObject = (UnityEngine.Object)((Component)gameObject).gameObject;
                            }
                            if (gameObject != (UnityEngine.Object)null)
                            {
                                if (flag2)
                                {
                                    EditorGUIUtility.PingObject(gameObject.GetInstanceID());
                                }
                                else if (flag3)
                                {
                                    Selection.objects = new List <UnityEngine.Object>()
                                    {
                                        gameObject
                                    }
                                }
Пример #2
0
        private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int threadIdx, float timeOffset, bool ghost)
        {
            float  num = (!ghost) ? 7f : 21f;
            string selectedPropertyPath = ProfilerDriver.selectedPropertyPath;
            bool   enterChildren        = true;
            Color  color        = GUI.color;
            Color  contentColor = GUI.contentColor;

            Color[] colors = ProfilerColors.colors;
            bool    flag   = false;
            float   x      = -1f;
            float   num2   = -1f;
            float   num3   = -1f;
            int     num4   = 0;
            float   num5   = -1f;
            string  text   = null;

            r.height -= 1f;
            GUI.BeginGroup(r);
            float num6 = 0f;

            r.y = num6;
            r.x = num6;
            bool  flag2     = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown;
            bool  flag3     = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown;
            Rect  shownArea = this.m_TimeArea.shownArea;
            float rectWidthDivShownWidth = r.width / shownArea.width;
            float x2 = r.x;
            float x3 = shownArea.x;

            while (iter.Next(enterChildren))
            {
                enterChildren = true;
                float num7       = iter.startTimeMS + timeOffset;
                float durationMS = iter.durationMS;
                float num8       = Mathf.Max(durationMS, 0.0003f);
                float num9       = ProfilerTimelineGUI.TimeToPixelCached(num7, rectWidthDivShownWidth, x3, x2);
                float num10      = ProfilerTimelineGUI.TimeToPixelCached(num7 + num8, rectWidthDivShownWidth, x3, x2) - 1f;
                float num11      = num10 - num9;
                if (num9 > r.x + r.width || num10 < r.x)
                {
                    enterChildren = false;
                }
                else
                {
                    float num12 = (float)(iter.depth - 1);
                    float num13 = r.y + num12 * 16f;
                    if (flag)
                    {
                        bool flag4 = false;
                        if (num11 >= num)
                        {
                            flag4 = true;
                        }
                        if (num3 != num13)
                        {
                            flag4 = true;
                        }
                        if (num9 - num2 > 6f)
                        {
                            flag4 = true;
                        }
                        if (flag4)
                        {
                            this.DrawSmallGroup(x, num2, num3, num4);
                            flag = false;
                        }
                    }
                    if (num11 < num)
                    {
                        enterChildren = false;
                        if (!flag)
                        {
                            flag = true;
                            num3 = num13;
                            x    = num9;
                            num4 = 0;
                        }
                        num2 = num10;
                        num4++;
                    }
                    else
                    {
                        int    id    = iter.id;
                        string path  = iter.path;
                        bool   flag5 = path == selectedPropertyPath && !ghost;
                        if (this.m_SelectedID >= 0)
                        {
                            flag5 &= (id == this.m_SelectedID);
                        }
                        flag5 &= (threadIdx == this.m_SelectedThread);
                        Color white  = Color.white;
                        Color color2 = colors[iter.group % colors.Length];
                        color2.a = ((!flag5) ? 0.75f : 1f);
                        if (ghost)
                        {
                            color2.a = 0.4f;
                            white.a  = 0.5f;
                        }
                        string text2 = iter.name;
                        if (flag5)
                        {
                            text = text2;
                            this.m_SelectedTime = num7;
                            this.m_SelectedDur  = durationMS;
                            num5 = num13 + 16f;
                        }
                        if (num11 < 20f)
                        {
                            text2 = string.Empty;
                        }
                        else
                        {
                            if (num11 < 50f && !flag5)
                            {
                                white.a *= (num11 - 20f) / 30f;
                            }
                            if (num11 > 200f)
                            {
                                text2 += string.Format(" ({0:f2}ms)", durationMS);
                            }
                        }
                        GUI.color        = color2;
                        GUI.contentColor = white;
                        Rect position = new Rect(num9, num13, num11, 14f);
                        GUI.Label(position, text2, ProfilerTimelineGUI.styles.bar);
                        if ((flag2 || flag3) && position.Contains(Event.current.mousePosition))
                        {
                            this.m_Window.SetSelectedPropertyPath(path);
                            this.m_SelectedThread = threadIdx;
                            this.m_SelectedID     = id;
                            UnityEngine.Object @object = EditorUtility.InstanceIDToObject(iter.instanceId);
                            if (@object is Component)
                            {
                                @object = ((Component)@object).gameObject;
                            }
                            if (@object != null)
                            {
                                if (flag2)
                                {
                                    EditorGUIUtility.PingObject(@object.GetInstanceID());
                                }
                                else
                                {
                                    if (flag3)
                                    {
                                        Selection.objects = new List <UnityEngine.Object>
                                        {
                                            @object
                                        }.ToArray();
                                    }
                                }
                            }
                            Event.current.Use();
                        }
                        flag = false;
                    }
                }
            }
            if (flag)
            {
                this.DrawSmallGroup(x, num2, num3, num4);
            }
            GUI.color        = color;
            GUI.contentColor = contentColor;
            if (text != null && threadIdx == this.m_SelectedThread)
            {
                string     text3   = string.Format(((double)this.m_SelectedDur < 1.0) ? "{0}\n{1:f3}ms" : "{0}\n{1:f2}ms", text, this.m_SelectedDur);
                GUIContent content = new GUIContent(text3);
                GUIStyle   tooltip = ProfilerTimelineGUI.styles.tooltip;
                Vector2    vector  = tooltip.CalcSize(content);
                float      num14   = this.m_TimeArea.TimeToPixel(this.m_SelectedTime + this.m_SelectedDur * 0.5f, r);
                if (num14 < r.x)
                {
                    num14 = r.x + 20f;
                }
                if (num14 > r.xMax)
                {
                    num14 = r.xMax - 20f;
                }
                Rect position2;
                if (num5 + 6f + vector.y < r.yMax)
                {
                    position2 = new Rect(num14 - 32f, num5, 50f, 7f);
                    GUI.Label(position2, GUIContent.none, ProfilerTimelineGUI.styles.tooltipArrow);
                }
                position2 = new Rect(num14, num5 + 6f, vector.x, vector.y);
                if (position2.xMax > r.xMax + 20f)
                {
                    position2.x = r.xMax - position2.width + 20f;
                }
                if (position2.yMax > r.yMax)
                {
                    position2.y = r.yMax - position2.height;
                }
                if (position2.y < r.y)
                {
                    position2.y = r.y;
                }
                GUI.Label(position2, content, tooltip);
            }
            if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
            {
                this.m_Window.ClearSelectedPropertyPath();
                this.m_SelectedID     = -1;
                this.m_SelectedThread = threadIdx;
                Event.current.Use();
            }
            GUI.EndGroup();
        }
Пример #3
0
        private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int frameIndex, int threadIndex, float timeOffset, bool ghost, bool includeSubSamples)
        {
            float  num = (!ghost) ? 7f : 21f;
            string selectedPropertyPath = ProfilerDriver.selectedPropertyPath;
            Color  color        = GUI.color;
            Color  contentColor = GUI.contentColor;

            Color[] colors = ProfilerColors.colors;
            bool    flag   = false;
            float   x      = -1f;
            float   num2   = -1f;
            float   num3   = -1f;
            int     num4   = 0;
            float   num5   = (!includeSubSamples) ? r.height : 16f;
            float   num6   = (float)((!includeSubSamples) ? 0 : 1);
            float   height = num5 - 2f * num6;

            r.height -= num6;
            GUI.BeginGroup(r);
            float num7 = 0f;

            r.y = num7;
            r.x = num7;
            bool  flag2     = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown;
            bool  flag3     = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown;
            Rect  shownArea = this.m_TimeArea.shownArea;
            float rectWidthDivShownWidth = r.width / shownArea.width;
            float x2            = r.x;
            float x3            = shownArea.x;
            bool  enterChildren = true;

            while (iter.Next(enterChildren))
            {
                enterChildren = includeSubSamples;
                float num8       = iter.startTimeMS + timeOffset;
                float durationMS = iter.durationMS;
                float num9       = Mathf.Max(durationMS, 0.0003f);
                float num10      = ProfilerTimelineGUI.TimeToPixelCached(num8, rectWidthDivShownWidth, x3, x2);
                float num11      = ProfilerTimelineGUI.TimeToPixelCached(num8 + num9, rectWidthDivShownWidth, x3, x2) - 1f;
                float num12      = num11 - num10;
                if (num10 > r.x + r.width || num11 < r.x)
                {
                    enterChildren = false;
                }
                else
                {
                    float num13 = (float)(iter.depth - 1);
                    float num14 = r.y + num13 * num5;
                    if (flag)
                    {
                        bool flag4 = false;
                        if (num12 >= num)
                        {
                            flag4 = true;
                        }
                        if (num3 != num14)
                        {
                            flag4 = true;
                        }
                        if (num10 - num2 > 6f)
                        {
                            flag4 = true;
                        }
                        if (flag4)
                        {
                            this.DrawSmallGroup(x, num2, num3, height, num4);
                            flag = false;
                        }
                    }
                    if (num12 < num)
                    {
                        enterChildren = false;
                        if (!flag)
                        {
                            flag = true;
                            num3 = num14;
                            x    = num10;
                            num4 = 0;
                        }
                        num2 = num11;
                        num4++;
                    }
                    else
                    {
                        int    instanceId = iter.instanceId;
                        string path       = iter.path;
                        bool   flag5      = path == selectedPropertyPath && !ghost;
                        if (this.m_SelectedEntry.instanceId >= 0)
                        {
                            flag5 &= (instanceId == this.m_SelectedEntry.instanceId);
                        }
                        flag5 &= (threadIndex == this.m_SelectedEntry.threadId);
                        Color white  = Color.white;
                        Color color2 = colors[iter.group % colors.Length];
                        color2.a = ((!flag5) ? 0.75f : 1f);
                        if (ghost)
                        {
                            color2.a = 0.4f;
                            white.a  = 0.5f;
                        }
                        string text = iter.name;
                        if (num12 < 20f || !includeSubSamples)
                        {
                            text = string.Empty;
                        }
                        else
                        {
                            if (num12 < 50f && !flag5)
                            {
                                white.a *= (num12 - 20f) / 30f;
                            }
                            if (num12 > 200f)
                            {
                                text += string.Format(" ({0:f2}ms)", durationMS);
                            }
                        }
                        GUI.color        = color2;
                        GUI.contentColor = white;
                        Rect position = new Rect(num10, num14, num12, height);
                        GUI.Label(position, text, ProfilerTimelineGUI.styles.bar);
                        if ((flag2 || flag3) && position.Contains(Event.current.mousePosition) && includeSubSamples)
                        {
                            this.m_Window.SetSelectedPropertyPath(path);
                            this.m_SelectedEntry.Reset();
                            this.m_SelectedEntry.frameId    = frameIndex;
                            this.m_SelectedEntry.threadId   = threadIndex;
                            this.m_SelectedEntry.instanceId = instanceId;
                            this.m_SelectedEntry.name       = iter.name;
                            if (iter.extraTooltipInfo != null)
                            {
                                this.m_SelectedEntry.metaData = iter.extraTooltipInfo;
                            }
                            this.m_SelectedEntry.time         = num8;
                            this.m_SelectedEntry.duration     = durationMS;
                            this.m_SelectedEntry.relativeYPos = num14 + num5;
                            this.UpdateSelectedObject(flag2, flag3);
                            Event.current.Use();
                        }
                        flag = false;
                    }
                }
            }
            if (flag)
            {
                this.DrawSmallGroup(x, num2, num3, height, num4);
            }
            GUI.color        = color;
            GUI.contentColor = contentColor;
            if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
            {
                this.ClearSelection();
                Event.current.Use();
            }
            GUI.EndGroup();
        }