コード例 #1
0
        void DisplayTimeline(ScrollView scrollView)
        {
            // Clear the scrollview
            scrollView.Clear();

            if (panel == null)
            {
                DisplayEmptyTimelinePanel(scrollView);
            }
            else
            {
                var calls = m_Debugger.GetBeginEndProcessedEvents(panel);
                if ((calls == null) || (calls.Count == 0))
                {
                    DisplayEmptyTimelinePanel(scrollView);
                    return;
                }

                long maxDuration = 0;
                foreach (var entry in calls)
                {
                    if (maxDuration < entry.duration)
                    {
                        maxDuration = entry.duration;
                    }
                }

                float currentTop = 5.0f;
                float lastPixel  = 0;
                float maxHeight  = 75.0f;
                foreach (var dbgObject in calls)
                {
                    var entry = new VisualElement();
                    entry.style.position        = Position.Absolute;
                    entry.style.backgroundColor = m_EventTypeFilter.m_Color.ContainsKey(dbgObject.eventBase.eventBaseName)
                        ? m_EventTypeFilter.m_Color[dbgObject.eventBase.eventBaseName]
                        : Color.black;
                    double percent     = dbgObject.duration / (double)maxDuration;
                    float  topPosition = currentTop + (float)((1 - percent) * 100);
                    entry.style.top    = (topPosition > (maxHeight - 5)) ? (maxHeight - 5) : topPosition;
                    entry.style.height = (maxHeight - topPosition) < 5 ? 5 : (maxHeight - topPosition);
                    entry.style.width  = 5;
                    entry.style.left   = lastPixel;
                    entry.tooltip      = dbgObject.eventBase.eventBaseName + " (" + dbgObject.duration / 1000 + " ms)";
                    scrollView.Add(entry);
                    lastPixel += 7;
                }

                scrollView.contentContainer.style.width = (lastPixel < 100) ? 100 : lastPixel;

                if (m_AutoScroll)
                {
                    scrollView.scrollOffset = new Vector2(lastPixel, 0);
                }
            }
        }