Esempio n. 1
0
        private void Initialize()
        {
            int len = ProfilerDriver.maxHistoryLength - 1;

            this.m_Charts = new ProfilerChart[7];
            Color[] colors = ProfilerColors.colors;
            for (ProfilerArea profilerArea = ProfilerArea.CPU; profilerArea < ProfilerArea.AreaCount; profilerArea++)
            {
                float           dataScale = 1f;
                Chart.ChartType type      = Chart.ChartType.Line;
                string[]        graphStatisticsPropertiesForArea = ProfilerDriver.GetGraphStatisticsPropertiesForArea(profilerArea);
                int             num = graphStatisticsPropertiesForArea.Length;
                if (profilerArea == ProfilerArea.GPU || profilerArea == ProfilerArea.CPU)
                {
                    type      = Chart.ChartType.StackedFill;
                    dataScale = 0.001f;
                }
                ProfilerChart profilerChart = new ProfilerChart(profilerArea, type, dataScale, num);
                for (int i = 0; i < num; i++)
                {
                    profilerChart.m_Series[i] = new ChartSeries(graphStatisticsPropertiesForArea[i], len, colors[i]);
                }
                this.m_Charts[(int)profilerArea] = profilerChart;
            }
            if (this.m_ReferenceListView == null)
            {
                this.m_ReferenceListView = new MemoryTreeList(this, null);
            }
            if (this.m_MemoryListView == null)
            {
                this.m_MemoryListView = new MemoryTreeListClickable(this, this.m_ReferenceListView);
            }
            this.UpdateCharts();
            this.BuildColumns();
            ProfilerChart[] charts = this.m_Charts;
            for (int j = 0; j < charts.Length; j++)
            {
                ProfilerChart profilerChart2 = charts[j];
                profilerChart2.LoadAndBindSettings();
            }
        }
Esempio n. 2
0
        void Initialize()
        {
            // When reinitializing (e.g. because Colorblind mode or PlatformModule changed) we don't need a new state
            if (m_AttachProfilerState == null)
            {
                m_AttachProfilerState = ConnectionUtility.GetAttachToPlayerState(this, (player) => ClearFramesCallback());
            }

            int historySize = ProfilerUserSettings.frameCount;

            m_Charts = new ProfilerChart[Profiler.areaCount];

            Color[] chartAreaColors = ProfilerColors.chartAreaColors;

            for (int i = 0; i < Profiler.areaCount; i++)
            {
                float           scale           = 1.0f;
                Chart.ChartType chartType       = Chart.ChartType.Line;
                string[]        statisticsNames = ProfilerDriver.GetGraphStatisticsPropertiesForArea((ProfilerArea)i);
                int             length          = statisticsNames.Length;
                if (Array.IndexOf(ms_StackedAreas, (ProfilerArea)i) != -1)
                {
                    chartType = Chart.ChartType.StackedFill;
                    scale     = 1.0f / 1000.0f;
                }

                ProfilerChart chart = CreateProfilerChart((ProfilerArea)i, chartType, scale, length);

                if (chart.m_Area == ProfilerArea.CPU)
                {
                    chart.SetOnSeriesToggleCallback(OnToggleCPUChartSeries);
                }

                for (int s = 0; s < length; s++)
                {
                    chart.m_Series[s] = new ChartSeriesViewData(statisticsNames[s], historySize, chartAreaColors[s % chartAreaColors.Length]);
                    for (int frameIdx = 0; frameIdx < historySize; ++frameIdx)
                    {
                        chart.m_Series[s].xValues[frameIdx] = (float)frameIdx;
                    }
                }

                m_Charts[(int)i] = chart;
            }

            if (m_VertSplit == null || m_VertSplit.relativeSizes == null || m_VertSplit.relativeSizes.Length == 0)
            {
                m_VertSplit = new SplitterState(new[] { 50f, 50f }, new[] { k_VertSplitterMinSizes, k_VertSplitterMinSizes }, null);
            }
            // 2 times the min splitter size plus one line height for the toolbar up top
            minSize = new Vector2(Chart.kSideWidth + k_RightPaneMinSize, k_VertSplitterMinSizes * m_VertSplit.minSizes.Length + k_LineHeight);

            // TODO: only create modules for active charts and otherwise lazy initialize them.
            if (m_ProfilerModules == null)
            {
                m_ProfilerModules = new ProfilerModuleBase[]
                {
                    new CPUProfilerModule(),                  //CPU
                    new GPUProfilerModule(),                  //GPU
                    new RenderingProfilerModule(),            //Rendering
                    new MemoryProfilerModule(),               //Memory
                    new AudioProfilerModule(),                //Audio
                    new VideoProfilerModule(),                //Video
                    new PhysicsProfilerModule(),              //Physics
                    new Physics2DProfilerModule(),            //Physics2D
                    new NetworkingMessagesProfilerModule(),   //NetworkMessages
                    new NetworkingOperationsProfilerModule(), //NetworkOperations
                    new UIProfilerModule(),                   //UI
                    new UIDetailsProfilerModule(),            //UIDetails
                    new GlobalIlluminationProfilerModule(),   //GlobalIllumination
                };
            }

            foreach (var module in m_ProfilerModules)
            {
                module?.OnEnable(this);
            }

            UpdateCharts();
            foreach (var chart in m_Charts)
            {
                chart.LoadAndBindSettings();
            }

            m_Initialized = true;
        }