Пример #1
0
        private void DrawThreadPopup(HierarchyFrameDataView frameDataView)
        {
            if (!frameDataView.valid)
            {
                var disabledValues = new string[] { m_ThreadName };
                EditorGUILayout.AdvancedPopup(0, disabledValues, BaseStyles.detailedViewTypeToolbarDropDown, GUILayout.Width(BaseStyles.detailedViewTypeToolbarDropDown.fixedWidth));
                return;
            }

            var newThreadIndex = 0;

            if (m_ThreadIndex == 0)
            {
                newThreadIndex = EditorGUILayout.AdvancedLazyPopup(m_ThreadName, m_ThreadIndex,
                                                                   (() => GetThreadNamesLazy(frameDataView)),
                                                                   BaseStyles.detailedViewTypeToolbarDropDown, GUILayout.Width(BaseStyles.detailedViewTypeToolbarDropDown.fixedWidth));
            }
            else
            {
                UpdateThreadNamesAndThreadIndex(frameDataView);
                newThreadIndex = EditorGUILayout.AdvancedPopup(m_ThreadIndex, m_ThreadNames, BaseStyles.detailedViewTypeToolbarDropDown, GUILayout.Width(BaseStyles.detailedViewTypeToolbarDropDown.fixedWidth));
            }

            if (newThreadIndex != m_ThreadIndex)
            {
                m_ThreadIndex = newThreadIndex;
                m_ThreadName  = m_ThreadNames[m_ThreadIndex];
            }
        }
Пример #2
0
        private void DrawThreadPopup(HierarchyFrameDataView frameDataView)
        {
            if (!frameDataView.valid)
            {
                var disabledValues = new string[] { m_ThreadName };
                EditorGUILayout.AdvancedPopup(0, disabledValues, BaseStyles.threadSelectionToolbarDropDown, GUILayout.MinWidth(BaseStyles.detailedViewTypeToolbarDropDown.fixedWidth));
                return;
            }

            var newThreadIndex = 0;

            if (threadIndex == 0)
            {
                newThreadIndex = EditorGUILayout.AdvancedLazyPopup(m_ThreadName, threadIndex,
                                                                   (() => GetThreadNamesLazy(frameDataView)),
                                                                   BaseStyles.threadSelectionToolbarDropDown, GUILayout.MinWidth(BaseStyles.detailedViewTypeToolbarDropDown.fixedWidth));
            }
            else
            {
                float minWidth, maxWidth;
                var   content = new GUIContent(m_ThreadName);
                BaseStyles.threadSelectionToolbarDropDown.CalcMinMaxWidth(content, out minWidth, out maxWidth);
                UpdateThreadNamesAndThreadIndex(frameDataView);
                newThreadIndex = EditorGUILayout.AdvancedPopup(threadIndex, m_ThreadNames, BaseStyles.threadSelectionToolbarDropDown, GUILayout.MinWidth(Math.Max(BaseStyles.detailedViewTypeToolbarDropDown.fixedWidth, minWidth)));
            }

            if (newThreadIndex != threadIndex)
            {
                threadIndex  = newThreadIndex;
                m_ThreadName = m_ThreadNames[threadIndex];
                EditorGUIUtility.ExitGUI();
            }
        }
        private void DrawThreadPopup(HierarchyFrameDataView frameDataView)
        {
            if (!frameDataView.valid)
            {
                var disabledValues = new string[] { m_ThreadName };
                EditorGUILayout.AdvancedPopup(0, disabledValues, BaseStyles.detailedViewTypeToolbarDropDown, GUILayout.Width(BaseStyles.detailedViewTypeToolbarDropDown.fixedWidth));
                return;
            }

            if (m_FrameIndex != frameDataView.frameIndex)
            {
                m_FrameIndex  = frameDataView.frameIndex;
                m_ThreadIndex = 0;

                using (var frameIterator = new ProfilerFrameDataIterator())
                {
                    var threadCount = frameIterator.GetThreadCount(m_FrameIndex);
                    m_ThreadNames   = new string[threadCount];
                    m_ThreadIndices = new int[threadCount];
                    for (var i = 0; i < threadCount; ++i)
                    {
                        frameIterator.SetRoot(m_FrameIndex, i);
                        var groupName  = frameIterator.GetGroupName();
                        var threadName = frameIterator.GetThreadName();
                        var name       = string.IsNullOrEmpty(groupName) ? threadName : groupName + "." + threadName;
                        m_ThreadNames[i]   = name;
                        m_ThreadIndices[i] = i;
                        if (m_ThreadName == name)
                        {
                            m_ThreadIndex = i;
                        }
                    }

                    Array.Sort(m_ThreadNames, m_ThreadIndices, new ThreadComparer());
                    for (var i = 0; i < threadCount; ++i)
                    {
                        if (m_ThreadName == m_ThreadNames[i])
                        {
                            m_ThreadIndex = i;
                        }
                    }
                }
            }

            var newThreadIndex = EditorGUILayout.AdvancedPopup(m_ThreadIndex, m_ThreadNames, BaseStyles.detailedViewTypeToolbarDropDown, GUILayout.Width(BaseStyles.detailedViewTypeToolbarDropDown.fixedWidth));

            if (newThreadIndex != m_ThreadIndex)
            {
                m_ThreadIndex = newThreadIndex;
                m_ThreadName  = m_ThreadNames[m_ThreadIndex];
            }
        }