Example #1
0
        protected override void RowGUI(RowGUIArgs args)
        {
            if (Event.current.rawType != EventType.Repaint)
            {
                return;
            }

            var item = (FrameDataTreeViewItem)args.item;

            item.Init(m_MultiColumnHeader.columns);

            for (var i = 0; i < args.GetNumVisibleColumns(); ++i)
            {
                var cellRect = args.GetCellRect(i);
                CellGUI(cellRect, item, i == 0, args.GetColumn(i), ref args);
            }

            // Tooltip logic only when item is selected
            if (!args.selected)
            {
                return;
            }

            var hovered = args.rowRect.Contains(Event.current.mousePosition);

            if (!hovered)
            {
                return;
            }

            // Framing hint when searching
            if (hasSearch)
            {
                GUIStyle.SetMouseTooltip(kFrameTooltip.tooltip, args.rowRect);
                return;
            }
        }
Example #2
0
        protected override void RowGUI(RowGUIArgs args)
        {
            switch (args.item)
            {
            case SystemTitleElement systemName:
            {
                var rect = args.GetCellRect(0);
                rect.xMin += GetContentIndent(systemName);

                GUI.Label(rect, args.item.displayName);
                break;
            }

            case SystemCreateElement systemCreate:
            {
                var rect = args.GetCellRect(0);
                rect.xMin += GetContentIndent(systemCreate);

                GUI.Label(rect, systemCreate.displayName);

                rect       = args.GetCellRect(1);
                rect.xMin += GetContentIndent(systemCreate);

                systemCreate.selectWorld = EditorGUI.Popup(args.GetCellRect(1), systemCreate.selectWorld,
                                                           World.AllWorlds.Select(w => w.Name).ToArray());
                rect       = args.GetCellRect(2);
                rect.xMin += GetContentIndent(systemCreate);

                if (GUI.Button(args.GetCellRect(2), "Create"))
                {
                    systemCreate.Create();
                }
                break;
            }
            }
        }
        /// <summary>
        /// TreeViewの列の描画
        /// </summary>
        protected override void RowGUI(RowGUIArgs args)
        {
            var item = args.item as TreeViewItem;

            for (var visibleColumnIndex = 0; visibleColumnIndex < args.GetNumVisibleColumns(); visibleColumnIndex++)
            {
                var rect = args.GetCellRect(visibleColumnIndex);
                rect.y      += 1f;
                rect.height -= 2f;

                var columnIndex = args.GetColumn(visibleColumnIndex);
                var labelStyle  = args.selected ? EditorStyles.whiteLabel : EditorStyles.label;
                labelStyle.alignment = TextAnchor.MiddleCenter;

                var element = baseElements[args.item.id];

                bool changeValue1 = false;
                bool changeValue2 = false;
                bool changeValue3 = false;
                bool changeValue4 = false;
                switch (columnIndex)
                {
                case 0:     // 備考
                    rect.x      += 2f;
                    rect.width  -= 4f;
                    element.Name = EditorGUI.TextField(rect, element.Name);
                    break;

                case 1:     // 数値1:数値2
                    rect.width -= valueFieldSpace + valueFieldMarginLeft + valueFieldMarginRight;
                    rect.width /= 2f;

                    EditorGUI.BeginChangeCheck();
                    rect.x        += valueFieldMarginLeft;
                    element.Value1 = EditorGUI.FloatField(rect, element.Value1);
                    changeValue1   = EditorGUI.EndChangeCheck();

                    rect.x += rect.width + valueFieldSpace;

                    EditorGUI.BeginChangeCheck();
                    element.Value2 = EditorGUI.FloatField(rect, element.Value2);
                    changeValue2   = EditorGUI.EndChangeCheck();
                    break;

                case 2:     // 数値3:数値4
                    rect.width -= valueFieldSpace + valueFieldMarginLeft + valueFieldMarginRight;
                    rect.width /= 2f;
                    rect.x     += valueFieldMarginLeft;

                    EditorGUI.BeginChangeCheck();
                    element.Value3 = EditorGUI.FloatField(rect, element.Value3);
                    changeValue3   = EditorGUI.EndChangeCheck();

                    rect.x += rect.width + valueFieldSpace;

                    EditorGUI.BeginChangeCheck();
                    element.Value4 = EditorGUI.FloatField(rect, element.Value4);
                    changeValue4   = EditorGUI.EndChangeCheck();
                    break;

                case 3:     // ボタン表示
                    rect.width /= 2;
                    if (GUI.Button(rect, "+"))
                    {
                        // 要素を複製して追加
                        baseElements.Insert(element.Id, new TreeElement
                        {
                            Name          = element.Name,
                            TemplateIndex = element.TemplateIndex,
                            Value1        = element.Value1,
                            Value2        = element.Value2,
                            Value3        = element.Value3,
                            Value4        = element.Value4,
                        });
                        Update();
                        Reload();
                    }
                    ;
                    rect.x += rect.width;

                    EditorGUI.BeginDisabledGroup(this.baseElements.Count <= 1);
                    if (GUI.Button(rect, "-"))
                    {
                        baseElements.RemoveAt(element.Id);
                        Update();
                        Reload();
                    }
                    ;
                    EditorGUI.EndDisabledGroup();
                    break;
                }

                if (changeValue1)
                {
                    element.UpdateValue4();
                }
                if (changeValue2)
                {
                    element.UpdateValue3();
                }
                if (changeValue3)
                {
                    element.UpdateValue4();
                }
                if (changeValue4)
                {
                    element.UpdateValue3();
                }
            }
        }
        protected override void RowGUI(RowGUIArgs args)
        {
            var item = (LuaProfilerTreeViewItem)args.item;

            if (m_gs == null)
            {
                m_gs           = new GUIStyle(GUI.skin.label);
                m_gs.alignment = TextAnchor.MiddleCenter;
            }
            var color = m_gs.normal.textColor;

            if (!this.IsSelected(item.id))
            {
                if (item.isLua)
                {
                    m_gs.normal.textColor = m_luaColor;
                }
                else if (item.isError)
                {
                    m_gs.normal.textColor = m_errorColor;
                }
                else
                {
                    m_gs.normal.textColor = m_monoColor;
                }
            }
            else
            {
                m_gs.normal.textColor = m_selectColor;
            }

            Rect r = args.GetCellRect(0);

            args.rowRect = r;
            base.RowGUI(args);

            r = args.GetCellRect(1);
            GUI.Label(r, GetMemoryString(item.totalLuaMemory), m_gs);

            r = args.GetCellRect(2);
            GUI.Label(r, GetMemoryString(item.selfLuaMemory), m_gs);

            r = args.GetCellRect(3);
            GUI.Label(r, GetMemoryString(item.totalMonoMemory), m_gs);

            r = args.GetCellRect(4);
            GUI.Label(r, GetMemoryString(item.selfMonoMemory), m_gs);

            r = args.GetCellRect(5);
            GUI.Label(r, GetMemoryString(item.showLuaGC), m_gs);

            r = args.GetCellRect(6);
            GUI.Label(r, GetMemoryString(item.showMonoGC), m_gs);

            r = args.GetCellRect(7);
            GUI.Label(r, ((float)item.currentTime / 10000).ToString("f2") + "ms", m_gs);

            r = args.GetCellRect(8);
            GUI.Label(r, ((float)item.selfCostTime / 10000).ToString("f2") + "ms", m_gs);

            r = args.GetCellRect(9);
            GUI.Label(r, ((float)item.averageTime / 10000).ToString("f2") + "ms", m_gs);

            r = args.GetCellRect(10);
            GUI.Label(r, ((float)item.totalTime / 10000000).ToString("f6") + "s", m_gs);

            r = args.GetCellRect(11);
            GUI.Label(r, GetMemoryString(item.totalCallTime, ""), m_gs);

            r = args.GetCellRect(12);
            GUI.Label(r, item.frameCalls.ToString(), m_gs);

            m_gs.normal.textColor = color;
        }
        protected override void RowGUI(RowGUIArgs args)
        {
            var buildReportItem = (BuildReportItem)args.item;

            for (var visibleColumnIndex = 0; visibleColumnIndex < args.GetNumVisibleColumns(); visibleColumnIndex++)
            {
                Rect rect;
                // Get the current cell rect and index
                if (visibleColumnIndex == 2)
                {
                    var rectOne = args.GetCellRect(visibleColumnIndex);
                    var rectTwo = args.GetCellRect(3);

                    rect = new Rect(rectOne.position, new Vector2(rectOne.width + rectTwo.width, rectOne.height));
                }
                else
                {
                    rect = args.GetCellRect(visibleColumnIndex);
                }

                var columnIndex = (TreeColumns)args.GetColumn(visibleColumnIndex);

                //Set label style to white if cell is selected otherwise to normal
                var labelStyle = args.selected ? Styles.TreeViewLabelSelected : Styles.TreeViewLabel;

                //Handle drawing of the columns
                switch (columnIndex)
                {
                case TreeColumns.Type:
                    GUI.Label(rect, buildReportItem.previewIcon, Styles.Center);
                    break;

                case TreeColumns.Name:
                    if (args.selected && buildReportItem.path != "")
                    {
                        EditorGUI.LabelField(rect, buildReportItem.path, labelStyle);
                    }
                    else
                    {
                        EditorGUI.LabelField(rect, buildReportItem.displayName, labelStyle);
                    }

                    break;

                case TreeColumns.Extension:
                    //EditorGUI.LabelField(rect, buildReportItem.extension, labelStyle);
                    break;

                case TreeColumns.Size:
                    EditorGUI.LabelField(rect, EditorUtility.FormatBytes(buildReportItem.size), labelStyle);
                    break;

                case TreeColumns.Percentage:
                    EditorGUI.LabelField(rect, buildReportItem.percentage.ToString("P"), labelStyle);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(columnIndex), columnIndex, null);
                }
            }
        }
Example #6
0
        protected override void RowGUI(RowGUIArgs args)
        {
            var item = (LuaProfilerTreeViewItem)args.item;

            if (m_gs == null)
            {
                m_gs           = new GUIStyle(GUI.skin.label);
                m_gs.alignment = TextAnchor.MiddleCenter;
            }
            Color color = m_gs.normal.textColor;

            if (item.line != -1)
            {
                m_gs.normal.textColor = Color.green;
            }
            Rect r = args.GetCellRect(0);

            args.rowRect = r;
            base.RowGUI(args);

            r = args.GetCellRect(1);
            GUI.Label(r, LuaProfiler.GetMemoryString(item.totalLuaMemory), m_gs);

            r = args.GetCellRect(2);
            GUI.Label(r, LuaProfiler.GetMemoryString(item.selfLuaMemory), m_gs);

            r = args.GetCellRect(3);
            GUI.Label(r, LuaProfiler.GetMemoryString(item.totalMonoMemory), m_gs);

            r = args.GetCellRect(4);
            GUI.Label(r, LuaProfiler.GetMemoryString(item.selfMonoMemory), m_gs);

            r = args.GetCellRect(5);
            GUI.Label(r, ((float)item.currentTime / 10000000).ToString("f6") + "s", m_gs);

            r = args.GetCellRect(6);
            GUI.Label(r, ((float)item.averageTime / 10000000).ToString("f6") + "s", m_gs);

            r = args.GetCellRect(7);
            GUI.Label(r, ((float)item.totalTime / 10000000).ToString("f6") + "s", m_gs);

            r = args.GetCellRect(8);
            GUI.Label(r, LuaProfiler.GetMemoryString(item.showLuaGC), m_gs);

            r = args.GetCellRect(9);
            GUI.Label(r, LuaProfiler.GetMemoryString(item.showMonoGC), m_gs);

            r = args.GetCellRect(10);
            GUI.Label(r, LuaProfiler.GetMemoryString(item.totalCallTime, ""), m_gs);

            r = args.GetCellRect(11);
            GUI.Label(r, item.frameCalls.ToString(), m_gs);

            m_gs.normal.textColor = color;
        }
Example #7
0
        protected override void RowGUI(RowGUIArgs args)
        {
            if (m_RightAlignedLabelStyle == null)
            {
                m_RightAlignedLabelStyle           = new GUIStyle(GUI.skin.label);
                m_RightAlignedLabelStyle.alignment = TextAnchor.MiddleRight;
            }

            for (int i = 0, n = args.GetNumVisibleColumns(); i < n; i++)
            {
                var rect = args.GetCellRect(i);
                var col  = (Column)args.GetColumn(i);
                int idx  = args.item.id - 1;
                switch (col)
                {
                case Column.FunctionName:
                {
                    if (m_Name[idx] == null)
                    {
                        var funcIndex = m_FunctionSamples[idx].Function;
                        if (funcIndex < 0)
                        {
                            m_Name[idx] = "???";
                        }
                        else
                        {
                            m_Name[idx] = m_Trace.Functions[funcIndex].Name.ToString();
                        }
                    }

                    EditorGUI.LabelField(rect, m_Name[idx]);
                    break;
                }

                case Column.ModuleName:
                {
                    if (m_Module[idx] == null)
                    {
                        var funcIndex = m_FunctionSamples[idx].Function;
                        if (funcIndex < 0)
                        {
                            m_Module[idx] = "???";
                        }
                        else
                        {
                            int moduleIndex = m_Trace.Functions[funcIndex].Module;
                            if (moduleIndex < 0)
                            {
                                m_Module[idx] = "???";
                            }
                            else
                            {
                                var    module = m_Trace.Modules[moduleIndex];
                                string name   = Path.GetFileName(module.FilePath.ToString());
                                if (module.IsMono)
                                {
                                    name += " (managed)";
                                }
                                m_Module[idx] = name;
                            }
                        }
                    }

                    EditorGUI.LabelField(rect, m_Module[idx]);
                    break;
                }

                case Column.Address:
                {
                    if (m_Addresses[idx] == null)
                    {
                        var funcIndex = m_FunctionSamples[idx].Function;
                        m_Addresses[idx] = funcIndex < 0 ? "???" : m_Trace.Functions[funcIndex].BaseAddress.ToString("X16");
                    }

                    EditorGUI.LabelField(rect, m_Addresses[idx]);
                    break;
                }

                case Column.SamplesSelf:
                {
                    if (m_NumSamplesSelf[idx] == null)
                    {
                        m_NumSamplesSelf[idx] = m_FunctionSamples[idx].Self.ToString();
                    }
                    EditorGUI.LabelField(rect, m_NumSamplesSelf[idx], m_RightAlignedLabelStyle);
                    break;
                }

                case Column.SamplesTotal:
                {
                    if (m_NumSamplesTotal[idx] == null)
                    {
                        m_NumSamplesTotal[idx] = m_FunctionSamples[idx].Total.ToString();
                    }
                    EditorGUI.LabelField(rect, m_NumSamplesTotal[idx], m_RightAlignedLabelStyle);
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Example #8
0
    protected override void RowGUI(RowGUIArgs args)
    {
        if (_descriptionStyle == null)
        {
            _descriptionStyle           = new GUIStyle("box");
            _descriptionStyle.alignment = TextAnchor.LowerLeft;
            _descriptionStyle.richText  = true;
            _descriptionStyle.wordWrap  = true;
        }

        BugTrackerTreeItem itm = args.item as BugTrackerTreeItem;

        BugReporterPlugin.IssueEntry issue = itm.entry;

        if (!itm.isDescription)
        {
            for (int i = 0; i < args.GetNumVisibleColumns(); ++i)
            {
                float indent = GetContentIndent(itm);
                Rect  r      = args.GetCellRect(i);
                int   column = args.GetColumn(i);
                int   idx    = column;

                switch (idx)
                {
                case 0:
                    if (_bugTrackerWindow.IsCurrentSceneIssue(issue) && GUI.Button(r, "Go"))
                    {
                        _bugTrackerWindow.GoToIssue(issue);
                    }
                    break;

                case 1:

                    r.x     += indent;
                    r.width -= indent;
                    EditorGUI.LabelField(r, issue.title);
                    break;

                case 2:
                    EditorGUI.LabelField(r, issue.assigneesString);
                    break;

                case 3:
                    EditorGUI.LabelField(r, issue.labelsString);
                    break;

                case 4:
                    EditorGUI.LabelField(r, issue.severity.ToString());
                    break;

                default:
                    break;
                }
            }
        }
        else
        {
            Rect r = args.rowRect;
            r.height -= BUTTON_ROW_HEIGHT;
            EditorGUI.LabelField(r, issue.description, _descriptionStyle);

            r.y     += r.height;
            r.height = BUTTON_ROW_HEIGHT;

            r.width = 200;
            if (GUI.Button(r, "Open in Browser"))
            {
                Application.OpenURL(issue.webUrl);
            }

            r.x += r.width;
            if (EditorGUIUtility.systemCopyBuffer == issue.webUrl)
            {
                EditorGUI.LabelField(r, "Url copied");
            }
            else if (GUI.Button(r, "Copy Url"))
            {
                EditorGUIUtility.systemCopyBuffer = issue.webUrl;
            }
        }
    }
        protected override void RowGUI(RowGUIArgs args)
        {
            if (m_RightAlignedLabelStyle == null)
            {
                m_RightAlignedLabelStyle           = new GUIStyle(GUI.skin.label);
                m_RightAlignedLabelStyle.alignment = TextAnchor.MiddleRight;
            }

            for (int i = 0, n = args.GetNumVisibleColumns(); i < n; i++)
            {
                var rect = args.GetCellRect(i);
                var col  = args.GetColumn(i);
                int idx  = args.item.id - 1;
                if (col == 0)
                {
                    if (m_Name[idx] == null)
                    {
                        var funcIndex = m_HeatMap.SamplesPerFunction[idx].Function;
                        if (funcIndex < 0)
                        {
                            m_Name[idx] = "???";
                        }
                        else
                        {
                            m_Name[idx] = m_Trace.Functions[funcIndex].Name.ToString();
                        }
                    }
                    EditorGUI.LabelField(rect, m_Name[idx]);
                }
                else if (col == 1)
                {
                    if (m_Module[idx] == null)
                    {
                        var funcIndex = m_HeatMap.SamplesPerFunction[idx].Function;
                        if (funcIndex < 0)
                        {
                            m_Module[idx] = "???";
                        }
                        else
                        {
                            int moduleIndex = m_Trace.Functions[funcIndex].Module;
                            if (moduleIndex < 0)
                            {
                                m_Module[idx] = "???";
                            }
                            else
                            {
                                var    module = m_Trace.Modules[moduleIndex];
                                string name   = Path.GetFileName(module.FilePath.ToString());
                                if (module.IsMono)
                                {
                                    name += " (managed)";
                                }
                                m_Module[idx] = name;
                            }
                        }
                    }
                    EditorGUI.LabelField(rect, m_Module[idx]);
                }
                else if (col == 2)
                {
                    if (m_Addresses[idx] == null)
                    {
                        var funcIndex = m_HeatMap.SamplesPerFunction[idx].Function;
                        m_Addresses[idx] = funcIndex < 0 ? "???" : m_Trace.Functions[funcIndex].BaseAddress.ToString("X16");
                    }
                    EditorGUI.LabelField(rect, m_Addresses[idx]);
                }
                else if (col == 3)
                {
                    if (m_NumSamples[idx] == null)
                    {
                        m_NumSamples[idx] = m_HeatMap.SamplesPerFunction[idx].Samples.ToString();
                    }
                    EditorGUI.LabelField(rect, m_NumSamples[idx], m_RightAlignedLabelStyle);
                }
            }
        }
        protected override void RowGUI(RowGUIArgs args)
        {
            var item = args.item as T;

            if (!item.serializedObject.targetObject)
            {
                return;
            }

            item.serializedObject.Update();

            var labelStyle = new GUIStyle(args.selected ? EditorStyles.whiteLabel : EditorStyles.label);

            var visibleColumnCount = args.GetNumVisibleColumns();

            for (var visibleColumnIndex = 0; visibleColumnIndex < visibleColumnCount; ++visibleColumnIndex)
            {
                var rect = args.GetCellRect(visibleColumnIndex);
                CenterRectUsingSingleLineHeight(ref rect);
                var columnIndex = args.GetColumn(visibleColumnIndex);
                var column      = multiColumnHeader.GetColumn(columnIndex) as IMultiColumn <T>;

                if (column.GetProperty == null)
                {
                    labelStyle.alignment = column.FieldAlignment;
                    EditorGUI.LabelField(rect, column.GetLabel(item), labelStyle);
                }
                else
                {
                    var sp = column.GetProperty(item);
                    if (column.IsVisible == null || column.IsVisible(item))
                    {
                        if (!column.HasCustomGUI)
                        {
                            using (var check = new EditorGUI.ChangeCheckScope())
                            {
                                EditorGUI.PropertyField(rect, sp, GUIContent.none);
                                if (check.changed)
                                {
                                    CopyToSelection(item.id, sp);
                                }
                            }
                        }
                        else
                        {
                            using (new EditorGUI.PropertyScope(rect, GUIContent.none, sp))
                                using (var check = new EditorGUI.ChangeCheckScope())
                                {
                                    switch (column)
                                    {
                                    case MultiColumn <T, bool> boolColumn:
                                        var newBool = EditorGUI.Toggle(rect, boolColumn.GetValue(item));
                                        if (check.changed)
                                        {
                                            boolColumn.SetValue(item, newBool);
                                            CopyToSelection(item.id, sp);
                                        }
                                        break;

                                    case MultiColumn <T, Enum> enumColumn:
                                        var newEnum = EditorGUI.EnumPopup(rect, enumColumn.GetValue(item));
                                        if (check.changed)
                                        {
                                            enumColumn.SetValue(item, newEnum);
                                            CopyToSelection(item.id, sp);
                                        }
                                        break;

                                    case MultiColumn <T, LayerMask> layerColumn:
                                        var newLayer = EditorGUI.LayerField(rect, layerColumn.GetValue(item));
                                        if (check.changed)
                                        {
                                            layerColumn.SetValue(item, newLayer);
                                            CopyToSelection(item.id, sp);
                                        }
                                        break;

                                    default:
                                        throw new InvalidOperationException("column value is unknown type");
                                    }
                                }
                        }
                    }
                }
            }
            if (canUndo ? item.serializedObject.ApplyModifiedProperties() : item.serializedObject.ApplyModifiedPropertiesWithoutUndo())
            {
                ModifiedItem?.Invoke(item);
            }
        }
Example #11
0
        protected override void RowGUI(RowGUIArgs args)
        {
            InitStyles();

            var idx = args.item.id;

            for (int i = 0, n = args.GetNumVisibleColumns(); i < n; i++)
            {
                var rect = args.GetCellRect(i);
                var col  = (Column)args.GetColumn(i);
                switch (col)
                {
                case Column.FunctionName:
                {
                    if (m_Name[idx] == null)
                    {
                        var funcIndex = m_TreeData.Frames[idx].FrameData.Function;
                        if (funcIndex < 0)
                        {
                            m_Name[idx] = "???";
                        }
                        else
                        {
                            m_Name[idx] = m_Trace.Functions[funcIndex].Name.ToString();
                        }
                    }
                    float indent = GetContentIndent(args.item);
                    rect.x     += indent;
                    rect.width -= indent;
                    EditorGUI.LabelField(rect, m_Name[idx]);
                    break;
                }

                case Column.ModuleName:
                {
                    if (m_Module[idx] == null)
                    {
                        var funcIndex = m_TreeData.Frames[idx].FrameData.Function;
                        if (funcIndex < 0)
                        {
                            m_Module[idx] = "???";
                        }
                        else
                        {
                            int moduleIndex = m_Trace.Functions[funcIndex].Module;
                            if (moduleIndex < 0)
                            {
                                m_Module[idx] = "???";
                            }
                            else
                            {
                                var    module = m_Trace.Modules[moduleIndex];
                                string name   = Path.GetFileName(module.FilePath.ToString());
                                if (module.IsMono)
                                {
                                    name += " (managed)";
                                }
                                if (module.FilePath.Contains(BurstCacheDir) || module.FilePath.LastIndexOf(BurstLib) != -1)
                                {
                                    name += " (Burst)";
                                }
                                m_Module[idx] = name;
                            }
                        }
                    }
                    EditorGUI.LabelField(rect, m_Module[idx]);
                    break;
                }

                case Column.Address:
                {
                    if (m_Addresses[idx] == null)
                    {
                        m_Addresses[idx] = m_TreeData.Frames[idx].FrameData.Address.ToString("X16");
                    }
                    EditorGUI.LabelField(rect, m_Addresses[idx]);
                    break;
                }

                case Column.TotalSamples:
                {
                    if (m_TotalSamples[idx] == null)
                    {
                        m_TotalSamples[idx] = m_TreeData.Frames[idx].NumSamplesTotal.ToString();
                    }

                    EditorGUI.LabelField(rect, m_TotalSamples[idx], m_RightAlignedLabelStyle);
                    break;
                }

                case Column.SelfSamples:
                {
                    if (m_SelfSamples[idx] == null)
                    {
                        m_SelfSamples[idx] = m_TreeData.Frames[idx].NumSamplesSelf.ToString();
                    }

                    EditorGUI.LabelField(rect, m_SelfSamples[idx], m_RightAlignedLabelStyle);
                    break;
                }

                default:
                    throw new System.ArgumentOutOfRangeException(nameof(col), col.ToString());
                }
            }
        }
Example #12
0
        protected override void RowGUI(RowGUIArgs args)
        {
            var apiTracker = ApiTracker.Instance;

            InitializeStyle();

            var item = args.item as ApiHistoryViewItem;

            var info = item.Info;

            var columns = Enum.GetValues(typeof(Column)).Cast <Column>().ToArray();

            for (var visibleColumnIndex = 0; visibleColumnIndex < args.GetNumVisibleColumns(); visibleColumnIndex++)
            {
                var rect        = args.GetCellRect(visibleColumnIndex);
                var columnIndex = args.GetColumn(visibleColumnIndex);

                var labelStyle = args.selected ? EditorStyles.whiteLabel : EditorStyles.label;

                labelStyle.alignment = TextAnchor.MiddleLeft;

                CenterRectUsingSingleLineHeight(ref rect);

                var column = columns.ElementAt(columnIndex);

                switch (column)
                {
                case Column.Status:
                {
                    var texture = requestStatusTexture.GetValueOrDefault(info.Status);

                    if (texture != null)
                    {
                        requestStatusStyle.normal.background = texture;
                    }

                    rect.position += new Vector2(4f, 4f);

                    EditorGUI.LabelField(rect, string.Empty, requestStatusStyle);
                }
                break;

                case Column.Type:
                {
                    var texture = statusLabelTexture.GetValueOrDefault(info.Request);

                    if (texture != null)
                    {
                        statusLabelStyle.normal.background = texture;
                    }

                    var requestName = info.Request.ToLabelName();

                    rect.position += new Vector2(4f, 2f);

                    EditorGUI.LabelField(rect, requestName, statusLabelStyle);
                }
                break;

                case Column.Api:
                {
                    var apiName = info.Url.Replace(apiTracker.ServerUrl, string.Empty);

                    EditorGUI.LabelField(rect, apiName, labelStyle);
                }
                break;

                case Column.StatusCode:
                    EditorGUI.LabelField(rect, info.StatusCode.IsNullOrEmpty() ? "---" : info.StatusCode, labelStyle);
                    break;

                case Column.ElapsedTime:
                    EditorGUI.LabelField(rect, info.ElapsedTime.HasValue ? info.ElapsedTime.ToString() : "---", labelStyle);
                    break;

                case Column.RetryCount:
                    EditorGUI.LabelField(rect, info.RetryCount.ToString(), labelStyle);
                    break;

                case Column.StartTime:
                    EditorGUI.LabelField(rect, info.Start.HasValue ? info.Start.ToString() : "---", labelStyle);
                    break;

                case Column.FinishTime:
                    EditorGUI.LabelField(rect, info.Finish.HasValue ? info.Finish.ToString() : "---", labelStyle);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(columnIndex), columnIndex, null);
                }
            }
        }
        /// <summary>
        /// TreeViewの列の描画
        /// </summary>
        protected override void RowGUI(RowGUIArgs args)
        {
            var item = args.item as TreeViewItem;

            for (var visibleColumnIndex = 0; visibleColumnIndex < args.GetNumVisibleColumns(); visibleColumnIndex++)
            {
                var rect = args.GetCellRect(visibleColumnIndex);
                rect.y += 1f;

                var columnIndex = args.GetColumn(visibleColumnIndex);

                var element = baseElements[args.item.id];

                bool changeTemplate = false;
                bool changeValue1   = false;
                bool changeRate     = false;
                switch (columnIndex)
                {
                case 0:     // 備考
                    rect.x      += 2f;
                    rect.width  -= 4f;
                    element.Name = EditorGUI.TextField(rect, element.Name);
                    break;

                case 1:     // 数値
                    EditorGUI.BeginChangeCheck();
                    element.Value1 = EditorGUI.FloatField(rect, element.Value1);
                    changeValue1   = EditorGUI.EndChangeCheck();
                    break;

                case 2:     // 係数
                    var rectTemplate = rect;
                    rectTemplate.width  = ratePopupWidth;
                    rect.width         -= ratePopupWidth;
                    rectTemplate.x      = rect.x + rect.width + 2f;
                    rectTemplate.width -= 1f;

                    EditorGUI.BeginChangeCheck();
                    element.Rate = EditorGUI.FloatField(rect, element.Rate);
                    changeRate   = EditorGUI.EndChangeCheck();   // 倍率を変更した

                    EditorGUI.BeginChangeCheck();
                    element.TemplateIndex = EditorGUI.Popup(rectTemplate, element.TemplateIndex, templatePopupDisplayNames);
                    changeTemplate        = EditorGUI.EndChangeCheck(); // テンプレートを変更した
                    break;

                case 3:     // 結果
                    EditorGUI.FloatField(rect, element.Value2);
                    break;

                case 4:     // ボタン
                    rect.width /= 2;
                    if (GUI.Button(rect, "+"))
                    {
                        baseElements.Insert(element.Id, new TreeElement
                        {
                            Name          = element.Name,
                            TemplateIndex = element.TemplateIndex,
                            Value1        = element.Value1,
                            Rate          = element.Rate,
                            Value2        = element.Value2,
                        });
                        Update();
                        Reload();
                    }
                    ;
                    rect.x += rect.width;

                    EditorGUI.BeginDisabledGroup(this.baseElements.Count <= 1);
                    if (GUI.Button(rect, "-"))
                    {
                        baseElements.RemoveAt(element.Id);
                        Update();
                        Reload();
                    }
                    ;
                    EditorGUI.EndDisabledGroup();
                    break;
                }

                if (changeTemplate)
                {
                    element.Rate = GetRateFromTemplate((ETemplateType)element.TemplateIndex, element.Rate);
                    changeRate   = true;
                }
                else
                if (changeRate)
                {
                    element.TemplateIndex = (int)ETemplateType.Custom;
                }

                if (changeValue1 || changeRate)
                {
                    element.Value2 = element.Value1 * element.Rate;
                }
            }
        }
Example #14
0
        protected override void RowGUI(RowGUIArgs args)
        {
            var muscleTreeViewItem = args.item as MuscleTreeItem;

            if (muscleTreeViewItem != null)
            {
                for (var i = 0; i < args.GetNumVisibleColumns(); i++)
                {
                    var rect       = args.GetCellRect(i);
                    var column     = (MuscleTreeColumn)args.GetColumn(i);
                    var labelStyle = args.selected ? EditorStyles.whiteLabel : EditorStyles.label;
                    var element    = muscleTreeViewItem.MuscleElement;
                    var index      = muscleTreeViewItem.MuscleElement.MuscleId;
                    switch (column)
                    {
                    case MuscleTreeColumn.InternalId:
                        break;

                    case MuscleTreeColumn.Id:
                        rect.x += 15;
                        EditorGUI.LabelField(rect, (index + 1).ToString(), labelStyle);
                        break;

                    case MuscleTreeColumn.CheckBox:
                        rect.x          += 25;
                        element.IsExport =
                            EditorGUI.Toggle(rect, element.IsExport);
                        break;

                    case MuscleTreeColumn.Name:
                        rect.x += 35;
                        EditorGUI.LabelField(rect, element.MuscleName, labelStyle);
                        break;

                    case MuscleTreeColumn.FloatValue:
                        var value = EditorGUI.Slider(rect, element.MuscleValue,
                                                     HumanTrait.GetMuscleDefaultMin(index),
                                                     HumanTrait.GetMuscleDefaultMax(index));
                        element.MuscleValue           = value;
                        this.humanPose.muscles[index] = value;
                        this.humanPoseHandler.SetHumanPose(ref this.humanPose);
                        break;

                    case MuscleTreeColumn.ResetButton:
                        if (GUI.Button(rect, "Reset"))
                        {
                            element.MuscleValue =
                                this.initialHumanPoseValues[index];
                            this.humanPose.muscles[index] =
                                element.MuscleValue;
                            this.humanPoseHandler.SetHumanPose(ref this.humanPose);
                        }

                        break;

                    default:
                        throw new ArgumentOutOfRangeException(Utility.NameOf(() => column), column, null);
                    }
                }
            }
            else
            {
                for (var i = 0; i < args.GetNumVisibleColumns(); i++)
                {
                    var rect           = args.GetCellRect(i);
                    var column         = (MuscleTreeColumn)args.GetColumn(i);
                    var boldLabelStyle = args.selected ? EditorStyles.whiteBoldLabel : EditorStyles.boldLabel;
                    var labelStyle     = args.selected ? EditorStyles.whiteLabel : EditorStyles.label;
                    var itemID         = args.item.id;
                    var value          = this.muscleRootFoldToggleTable[args.item.displayName + ":" + itemID];
                    switch (column)
                    {
                    case MuscleTreeColumn.InternalId:
                        break;

                    case MuscleTreeColumn.Id:
                        rect.x += 5;
                        EditorGUI.LabelField(rect, args.item.id.ToString(), labelStyle);
                        break;

                    case MuscleTreeColumn.CheckBox:
                        rect.x   += 15;
                        rect.xMax = rect.x + 15;
                        var toggle = EditorGUI.Toggle(rect, value);
                        if (value != toggle)
                        {
                            foreach (var treeViewItem in this.rootItem.children
                                     .First(x => x.displayName == args.item.displayName).children
                                     .Cast <MuscleTreeItem>())
                            {
                                treeViewItem.MuscleElement.IsExport = toggle;
                            }
                            this.muscleRootFoldToggleTable[args.item.displayName + ":" + itemID] = toggle;
                        }

                        break;

                    case MuscleTreeColumn.Name:
                        this.columnIndexForTreeFoldouts = 3;

                        rect.x += this.foldoutWidth + 2;
                        EditorGUI.LabelField(rect, args.item.displayName,
                                             boldLabelStyle);
                        break;

                    case MuscleTreeColumn.FloatValue:
                        break;

                    case MuscleTreeColumn.ResetButton:
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(Utility.NameOf(() => column), column, null);
                    }
                }
            }
        }
Example #15
0
        protected override void RowGUI(RowGUIArgs args)
        {
            var wi = WatchRegistry.Watches[args.item.id];

            string value = null;

            if (wi.StringAccessor == null)
            {
                wi.StringAccessor = WatchRegistry.CreateStringAccessor(wi.Watch, wi.Watch);
            }
            if (wi.StringAccessor != null)
            {
                if (!wi.StringAccessor.TryGet(out value))
                {
                    value = "<?>";
                }
            }
            else
            {
                value = $"<No string accessor for type '{wi.Watch.GetValueType().Name}'>";
            }
            for (int iVisCol = 0; iVisCol != args.GetNumVisibleColumns(); ++iVisCol)
            {
                var i    = args.GetColumn(iVisCol);
                var rect = args.GetCellRect(iVisCol);
                switch (i)
                {
                case kColumnIndexName:
                    DefaultGUI.Label(rect, wi.Watch.GetName(), args.selected, args.focused);
                    break;

                case kColumnIndexValue:
                    DefaultGUI.Label(rect, value, args.selected, args.focused);
                    break;

                case kColumnIndexType:
                    DefaultGUI.Label(rect, wi.Watch.GetValueType().Name, args.selected, args.focused);
                    break;

                case kColumnIndexContext:
                    DefaultGUI.Label(rect, wi.Watch.GetContextName(), args.selected, args.focused);
                    break;

                case kColumnIndexVisualization:
                    if (WatchRegistry.WatchTypeRegistry.TryGetTypeInfo(wi.Watch.GetValueType(), out var ti))
                    {
                        GUILayout.BeginArea(rect);
                        GUILayout.BeginHorizontal();
                        foreach (var nameVisFact in ti.Visualizers)
                        {
                            bool hasVis = wi.TryGetWatchVisualizer(nameVisFact.Key, out var vis);
                            if (GUILayout.Toggle(hasVis, new GUIContent(nameVisFact.Key, nameVisFact.Value.GetDescription()), "Button"))
                            {
                                if (!hasVis)
                                {
                                    wi.TryAddVisualizer(nameVisFact.Value, wi.Watch, out vis);
                                }
                            }
                            else
                            {
                                if (hasVis)
                                {
                                    wi.TryRemoveWatchVisualizer(vis);
                                }
                            }
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.EndArea();
                    }
                    break;
                }
            }
        }