Ejemplo n.º 1
0
        /// <summary>
        /// Draws the body GUI section
        /// </summary>
        /// <param name="settings"></param>
        public virtual void DrawContent(GenesisSettings settings)
        {
            // The default implementation for draw content enables its content to be collapsed via a foldout header bar.
            _drawContent = EditorGUILayoutTools.DrawSectionHeaderToggle(Title, _drawContent);
            if (!_drawContent)
            {
                return;
            }

            EditorGUILayoutTools.BeginSectionContent();
            DrawContentBody(settings);
            EditorGUILayoutTools.EndSectionContent();
        }
        private void DrawSystemList(DebugSystems systems)
        {
            _showSystemsList = EditorGUILayoutTools.DrawSectionHeaderToggle(SYSTEMS_TITLE, _showSystemsList);
            if (_showSystemsList)
            {
                using (new EditorGUILayout.VerticalScope(EntitasReduxStyles.SectionContent))
                {
                    EditorGUILayout.HelpBox(SYSTEMS_DESCRIPTION, MessageType.Info);

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        DebugSystems.avgResetInterval = (AvgResetInterval)EditorGUILayout.EnumPopup(
                            RESET_AVERAGE_DURATION_LABEL,
                            DebugSystems.avgResetInterval);

                        if (GUILayout.Button(RESET_AVERAGE_NOW_LABEL, EditorStyles.miniButton, GUILayout.Width(150f)))
                        {
                            systems.ResetDurations();
                        }
                    }

                    _threshold = EditorGUILayout.Slider(
                        THRESHOLD_SLIDER_LABEL,
                        _threshold,
                        0f,
                        33f);

                    _hideEmptySystems = EditorGUILayout.Toggle(HIDE_EMPTY_SYSTEMS_LABEL, _hideEmptySystems);
                    EditorGUILayout.Space();

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        _systemSortMethod = (SortMethod)EditorGUILayout.EnumPopup(
                            _systemSortMethod,
                            EditorStyles.popup,
                            GUILayout.Width(150));
                        _systemNameSearchString = EditorGUILayoutTools.SearchTextField(_systemNameSearchString);
                    }

                    EditorGUILayout.Space();

                    DrawSystemSection(INITIALIZE_SYSTEMS_TITLE, ref _showInitializeSystems, systems, SystemInterfaceFlags.InitializeSystem);
                    DrawSystemSection(FIXED_UPDATE_SYSTEMS_TITLE, ref _showFixedUpdateSystems, systems, SystemInterfaceFlags.FixedUpdateSystem);
                    DrawSystemSection(UPDATE_SYSTEMS_TITLE, ref _showUpdateSystems, systems, SystemInterfaceFlags.UpdateSystem);
                    DrawSystemSection(LATE_UPDATE_SYSTEMS_TITLE, ref _showLateUpdateSystems, systems, SystemInterfaceFlags.LateUpdateSystem);
                    DrawSystemSection(REACTIVE_SYSTEMS_TITLE, ref _showReactiveSystems, systems, SystemInterfaceFlags.ReactiveSystem);
                    DrawSystemSection(CLEANUP_SYSTEMS_TITLE, ref _showCleanupSystems, systems, SystemInterfaceFlags.CleanupSystem);
                    DrawSystemSection(TEARDOWN_SYSTEMS_TITLE, ref _showTearDownSystems, systems, SystemInterfaceFlags.TearDownSystem);
                }
            }
        }
 private void DrawSystemSection(string header,
                                ref bool showSystems,
                                DebugSystems systems,
                                SystemInterfaceFlags systemInterfaceFlags)
 {
     showSystems = EditorGUILayoutTools.DrawSectionHeaderToggle(header, showSystems);
     if (showSystems && ShouldShowSystems(systems, systemInterfaceFlags))
     {
         using (new EditorGUILayout.VerticalScope(EntitasReduxStyles.SectionContent))
         {
             var systemsDrawn = DrawSystemInfos(systems, systemInterfaceFlags);
             if (systemsDrawn == 0)
             {
                 EditorGUILayout.LabelField(string.Empty);
             }
         }
     }
 }
 private static void DrawSystemsOverview(DebugSystems systems)
 {
     _showDetails = EditorGUILayoutTools.DrawSectionHeaderToggle(DETAILS_TITLE, _showDetails);
     if (_showDetails)
     {
         using (new EditorGUILayout.VerticalScope(EntitasReduxStyles.SectionContent))
         {
             EditorGUILayout.LabelField(INITIALIZE_SYSTEMS_COUNT_LABEL, systems.TotalInitializeSystemsCount.ToString());
             EditorGUILayout.LabelField(FIXED_UPDATE_SYSTEMS_COUNT_LABEL, systems.TotalFixedUpdateSystemsCount.ToString());
             EditorGUILayout.LabelField(UPDATE_SYSTEMS_COUNT_LABEL, systems.TotalUpdateSystemsCount.ToString());
             EditorGUILayout.LabelField(LATE_UPDATE_SYSTEMS_COUNT_LABEL, systems.TotalLateUpdateSystemsCount.ToString());
             EditorGUILayout.LabelField(REACTIVE_SYSTEMS_COUNT_LABEL, systems.TotalReactiveSystemsCount.ToString());
             EditorGUILayout.LabelField(CLEANUP_SYSTEMS_COUNT_LABEL, systems.TotalCleanupSystemsCount.ToString());
             EditorGUILayout.LabelField(TEARDOWN_SYSTEMS_COUNT_LABEL, systems.TotalTearDownSystemsCount.ToString());
             EditorGUILayout.LabelField(TOTAL_SYSTEMS_COUNT_LABEL, systems.TotalSystemsCount.ToString());
         }
     }
 }
        private void DrawSystemsMonitor(DebugSystems systems)
        {
            _showSystemsMonitor = EditorGUILayoutTools.DrawSectionHeaderToggle(PERFORMANCE_TITLE, _showSystemsMonitor);
            if (_showSystemsMonitor)
            {
                using (new EditorGUILayout.VerticalScope(VisualDebugStyles.SectionContent))
                {
                    // Draw Average Performance Stats
                    using (new EditorGUILayout.VerticalScope())
                    {
                        EditorGUILayout.LabelField(AVERAGE_PERFORMANCE_TITLE, EditorStyles.boldLabel);

                        DrawDurationLabel(FIXED_UPDATE_DURATION_LABEL, systems.AverageFixedUpdateDuration);
                        DrawDurationLabel(UPDATE_DURATION_LABEL, systems.AverageUpdateDuration);
                        DrawDurationLabel(LATE_UPDATE_DURATION_LABEL, systems.AverageLateUpdateDuration);
                        DrawDurationLabel(REACTIVE_DURATION_LABEL, systems.AverageReactiveDuration);
                        DrawDurationLabel(CLEANUP_DURATION_LABEL, systems.AverageCleanupDuration);
                    }

                    // Draw Legend
                    using (var legendScope = new EditorGUILayout.VerticalScope())
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.LabelField(GRAPH_LEGEND, EditorStyles.boldLabel, GUILayout.Width(60f));
                            GUILayout.FlexibleSpace();
                        }

                        GUILayout.Space(5);

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            DrawLegendLabel(FIXED_UPDATE_LEGEND, VisualDebuggingPreferences.FixedUpdateColor);
                            GUILayout.FlexibleSpace();

                            DrawLegendLabel(UPDATE_LEGEND, VisualDebuggingPreferences.UpdateColor);
                            GUILayout.FlexibleSpace();

                            DrawLegendLabel(LATE_UPDATE_LEGEND, VisualDebuggingPreferences.LateUpdateColor);
                        }
                    }

                    EditorGUILayout.Space(5);

                    // Update Graph
                    if (!EditorApplication.isPaused)
                    {
                        AddSystemDurations(systems);
                    }

                    // Draw Graph
                    const float GRAPH_HEIGHT = 100f;
                    _systemsMonitor.Draw(
                        new[]
                    {
                        _fixedUpdateSystemMonitorData.ToArray(),
                        _updateSystemMonitorData.ToArray(),
                        _lateUpdateSystemMonitorData.ToArray()
                    },
                        Screen.width,
                        GRAPH_HEIGHT,
                        new[]
                    {
                        VisualDebuggingPreferences.FixedUpdateColor,
                        VisualDebuggingPreferences.UpdateColor,
                        VisualDebuggingPreferences.LateUpdateColor
                    });
                }
            }
        }