示例#1
0
            public void OnGUI(Rect rect, bool allowSorting, GUIStyle headerStyle)
            {
                GUI.BeginClip(rect);
                float num             = -this.m_TreeViewState.scrollPos.x;
                int   lastColumnIndex = AudioProfilerGroupInfoHelper.GetLastColumnIndex();

                for (int i = 0; i <= lastColumnIndex; i++)
                {
                    Rect position = new Rect(num, 0f, this.columnWidths[i], rect.height - 1f);
                    num += this.columnWidths[i];
                    Rect  position2 = new Rect(num - this.dragWidth / 2f, 0f, 3f, rect.height);
                    float x         = EditorGUI.MouseDeltaReader(position2, true).x;
                    if (x != 0f)
                    {
                        this.columnWidths[i] += x;
                        this.columnWidths[i]  = Mathf.Max(this.columnWidths[i], this.minColumnWidth);
                    }
                    string text = this.headers[i];
                    if (allowSorting && i == this.m_TreeViewState.selectedColumn)
                    {
                        text += ((!this.m_TreeViewState.sortByDescendingOrder) ? " ▲" : " ▼");
                    }
                    GUI.Box(position, text, headerStyle);
                    if (allowSorting && Event.current.type == EventType.MouseDown && position.Contains(Event.current.mousePosition))
                    {
                        this.m_TreeViewState.SetSelectedColumn(i);
                        this.m_Backend.UpdateSorting();
                    }
                    if (Event.current.type == EventType.Repaint)
                    {
                        EditorGUIUtility.AddCursorRect(position2, MouseCursor.SplitResizeLeftRight);
                    }
                }
                GUI.EndClip();
            }
 public void Init(Rect rect, AudioProfilerGroupViewBackend backend)
 {
     if (this.m_HeaderStyle == null)
     {
         this.m_HeaderStyle = new GUIStyle("OL title");
     }
     this.m_HeaderStyle.alignment = TextAnchor.MiddleLeft;
     if (this.m_TreeView == null)
     {
         this.m_Backend = backend;
         if (this.m_TreeViewState.columnWidths == null)
         {
             int num = AudioProfilerGroupInfoHelper.GetLastColumnIndex() + 1;
             this.m_TreeViewState.columnWidths = new float[num];
             for (int i = 2; i < num; i++)
             {
                 this.m_TreeViewState.columnWidths[i] = (((i != 2) && (i != 3)) && ((i < 11) || (i > 0x10))) ? ((float)60) : ((float)0x4b);
             }
             this.m_TreeViewState.columnWidths[0] = 140f;
             this.m_TreeViewState.columnWidths[1] = 140f;
         }
         this.m_TreeView = new TreeViewController(this.m_EditorWindow, this.m_TreeViewState);
         ITreeViewGUI        gui  = new AudioProfilerGroupViewGUI(this.m_TreeView);
         ITreeViewDataSource data = new AudioProfilerDataSource(this.m_TreeView, this.m_Backend);
         this.m_TreeView.Init(rect, data, gui, null);
         this.m_ColumnHeader = new AudioProfilerGroupViewColumnHeader(this.m_TreeViewState, this.m_Backend);
         this.m_ColumnHeader.columnWidths         = this.m_TreeViewState.columnWidths;
         this.m_ColumnHeader.minColumnWidth       = 30f;
         this.m_TreeView.selectionChangedCallback = (Action <int[]>)Delegate.Combine(this.m_TreeView.selectionChangedCallback, new Action <int[]>(this.OnTreeSelectionChanged));
     }
 }
 protected override void OnContentGUI(Rect rect, int row, TreeViewItem item, string label, bool selected, bool focused, bool useBoldFont, bool isPinging)
 {
     if (Event.current.type == EventType.Repaint)
     {
         GUIStyle gUIStyle = (!useBoldFont) ? TreeViewGUI.s_Styles.lineStyle : TreeViewGUI.s_Styles.lineBoldStyle;
         gUIStyle.alignment    = TextAnchor.MiddleLeft;
         gUIStyle.padding.left = 0;
         int num = 2;
         base.OnContentGUI(new Rect(rect.x, rect.y, this.columnWidths[0] - (float)num, rect.height), row, item, label, selected, focused, useBoldFont, isPinging);
         rect.x += this.columnWidths[0] + (float)num;
         AudioProfilerGroupView.AudioProfilerGroupTreeViewItem audioProfilerGroupTreeViewItem = item as AudioProfilerGroupView.AudioProfilerGroupTreeViewItem;
         for (int i = 1; i < this.columnWidths.Length; i++)
         {
             rect.width = this.columnWidths[i] - (float)(2 * num);
             gUIStyle.Draw(rect, AudioProfilerGroupInfoHelper.GetColumnString(audioProfilerGroupTreeViewItem.info, (AudioProfilerGroupInfoHelper.ColumnIndices)i), false, false, selected, focused);
             Handles.color = Color.black;
             Handles.DrawLine(new Vector3(rect.x - (float)num + 1f, rect.y, 0f), new Vector3(rect.x - (float)num + 1f, rect.y + rect.height, 0f));
             rect.x            += this.columnWidths[i];
             gUIStyle.alignment = TextAnchor.MiddleRight;
         }
         gUIStyle.alignment = TextAnchor.MiddleLeft;
     }
 }
        public static string GetColumnString(AudioProfilerGroupInfoWrapper info, AudioProfilerGroupInfoHelper.ColumnIndices index)
        {
            bool   flag  = (info.info.flags & 1) != 0;
            bool   flag2 = (info.info.flags & 64) != 0;
            string result;

            switch (index)
            {
            case AudioProfilerGroupInfoHelper.ColumnIndices.ObjectName:
                result = info.objectName;
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.AssetName:
                result = info.assetName;
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.Volume:
                result = AudioProfilerGroupInfoHelper.FormatDb(info.info.volume);
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.Audibility:
                result = ((!flag2) ? AudioProfilerGroupInfoHelper.FormatDb(info.info.audibility) : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.PlayCount:
                result = ((!flag2) ? info.info.playCount.ToString() : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.Is3D:
                result = ((!flag2) ? ((!flag) ? "NO" : (((info.info.flags & 2) == 0) ? "YES" : "Spatial")) : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsPaused:
                result = ((!flag2) ? (((info.info.flags & 4) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsMuted:
                result = ((!flag2) ? (((info.info.flags & 8) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsVirtual:
                result = ((!flag2) ? (((info.info.flags & 16) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsOneShot:
                result = ((!flag2) ? (((info.info.flags & 32) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsLooped:
                result = ((!flag2) ? (((info.info.flags & 512) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.DistanceToListener:
                result = ((!flag2) ? (flag ? ((info.info.distanceToListener < 1000f) ? string.Format("{0:0.00} m", info.info.distanceToListener) : string.Format("{0:0.00} km", info.info.distanceToListener * 0.001f)) : "N/A") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.MinDist:
                result = ((!flag2) ? (flag ? ((info.info.minDist < 1000f) ? string.Format("{0:0.00} m", info.info.minDist) : string.Format("{0:0.00} km", info.info.minDist * 0.001f)) : "N/A") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.MaxDist:
                result = ((!flag2) ? (flag ? ((info.info.maxDist < 1000f) ? string.Format("{0:0.00} m", info.info.maxDist) : string.Format("{0:0.00} km", info.info.maxDist * 0.001f)) : "N/A") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.Time:
                result = ((!flag2) ? string.Format("{0:0.00} s", info.info.time) : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.Duration:
                result = ((!flag2) ? string.Format("{0:0.00} s", info.info.duration) : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.Frequency:
                result = ((!flag2) ? ((info.info.frequency < 1000f) ? string.Format("{0:0.00} Hz", info.info.frequency) : string.Format("{0:0.00} kHz", info.info.frequency * 0.001f)) : string.Format("{0:0.00} x", info.info.frequency));
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsStream:
                result = ((!flag2) ? (((info.info.flags & 128) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsCompressed:
                result = ((!flag2) ? (((info.info.flags & 256) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsNonBlocking:
                result = ((!flag2) ? (((info.info.flags & 8192) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsOpenUser:
                result = ((!flag2) ? (((info.info.flags & 4096) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsOpenMemory:
                result = ((!flag2) ? (((info.info.flags & 1024) == 0) ? "NO" : "YES") : "");
                break;

            case AudioProfilerGroupInfoHelper.ColumnIndices.IsOpenMemoryPoint:
                result = ((!flag2) ? (((info.info.flags & 2048) == 0) ? "NO" : "YES") : "");
                break;

            default:
                result = "Unknown";
                break;
            }
            return(result);
        }