UnityEditor.ProfilerWindow.UpdateChartGrid C# (CSharp) Method

UpdateChartGrid() private static method

private static UpdateChartGrid ( float timeMax, ChartData data ) : void
timeMax float
data ChartData
return void
        private static void UpdateChartGrid(float timeMax, ChartData data)
        {
            if (timeMax < 1500f)
            {
                string[] labels = new string[] { "1ms (1000FPS)", "0.25ms (4000FPS)", "0.1ms (10000FPS)" };
                data.SetGrid(new float[] { 1000f, 250f, 100f }, labels);
            }
            else if (timeMax < 10000f)
            {
                string[] textArray2 = new string[] { "8ms (120FPS)", "4ms (250FPS)", "1ms (1000FPS)" };
                data.SetGrid(new float[] { 8333f, 4000f, 1000f }, textArray2);
            }
            else if (timeMax < 30000f)
            {
                string[] textArray3 = new string[] { "16ms (60FPS)", "10ms (100FPS)", "5ms (200FPS)" };
                data.SetGrid(new float[] { 16667f, 10000f, 5000f }, textArray3);
            }
            else if (timeMax < 100000f)
            {
                string[] textArray4 = new string[] { "66ms (15FPS)", "33ms (30FPS)", "16ms (60FPS)" };
                data.SetGrid(new float[] { 66667f, 33333f, 16667f }, textArray4);
            }
            else
            {
                string[] textArray5 = new string[] { "500ms (2FPS)", "200ms (5FPS)", "66ms (15FPS)" };
                data.SetGrid(new float[] { 500000f, 200000f, 66667f }, textArray5);
            }
        }

Usage Example

示例#1
0
        private void UpdateCharts()
        {
            int num  = ProfilerDriver.maxHistoryLength - 1;
            int num2 = ProfilerDriver.lastFrameIndex - num;
            int num3 = Mathf.Max(ProfilerDriver.firstFrameIndex, num2);

            ProfilerChart[] charts = this.m_Charts;
            for (int i = 0; i < charts.Length; i++)
            {
                ProfilerChart profilerChart = charts[i];
                float[]       array         = new float[profilerChart.m_Series.Length];
                for (int j = 0; j < profilerChart.m_Series.Length; j++)
                {
                    int   statisticsIdentifier = ProfilerDriver.GetStatisticsIdentifier(profilerChart.m_Series[j].identifierName);
                    float num4;
                    ProfilerDriver.GetStatisticsValues(statisticsIdentifier, num2, profilerChart.m_DataScale, profilerChart.m_Series[j].data, out num4);
                    num4 = Mathf.Max(num4, 0.0001f);
                    float num5;
                    if (profilerChart.m_Type == Chart.ChartType.Line)
                    {
                        num5 = 1f / (num4 * (1.05f + (float)j * 0.05f));
                    }
                    else
                    {
                        num5 = 1f / num4;
                    }
                    array[j] = num5;
                }
                if (profilerChart.m_Type == Chart.ChartType.Line)
                {
                    profilerChart.m_Data.AssignScale(array);
                }
                profilerChart.m_Data.Assign(profilerChart.m_Series, num2, num3);
            }
            string        selectedPropertyPath = ProfilerDriver.selectedPropertyPath;
            bool          flag           = selectedPropertyPath != string.Empty && this.m_CurrentArea == ProfilerArea.CPU;
            ProfilerChart profilerChart2 = this.m_Charts[0];

            if (flag)
            {
                profilerChart2.m_Data.hasOverlay = true;
                ChartSeries[] series = profilerChart2.m_Series;
                for (int k = 0; k < series.Length; k++)
                {
                    ChartSeries chartSeries           = series[k];
                    int         statisticsIdentifier2 = ProfilerDriver.GetStatisticsIdentifier("Selected" + chartSeries.identifierName);
                    chartSeries.CreateOverlayData();
                    float num6;
                    ProfilerDriver.GetStatisticsValues(statisticsIdentifier2, num2, profilerChart2.m_DataScale, chartSeries.overlayData, out num6);
                }
            }
            else
            {
                profilerChart2.m_Data.hasOverlay = false;
            }
            for (ProfilerArea profilerArea = ProfilerArea.CPU; profilerArea <= ProfilerArea.GPU; profilerArea++)
            {
                ProfilerChart profilerChart3 = this.m_Charts[(int)profilerArea];
                float         num7           = 0f;
                float         num8           = 0f;
                for (int l = 0; l < num; l++)
                {
                    float num9 = 0f;
                    for (int m = 0; m < profilerChart3.m_Series.Length; m++)
                    {
                        if (profilerChart3.m_Series[m].enabled)
                        {
                            num9 += profilerChart3.m_Series[m].data[l];
                        }
                    }
                    if (num9 > num7)
                    {
                        num7 = num9;
                    }
                    if (num9 > num8 && l + num2 >= num3 + 1)
                    {
                        num8 = num9;
                    }
                }
                if (num8 != 0f)
                {
                    num7 = num8;
                }
                num7 = Math.Min(num7, this.m_ChartMaxClamp);
                if (this.m_ChartOldMax[(int)profilerArea] > 0f)
                {
                    num7 = Mathf.Lerp(this.m_ChartOldMax[(int)profilerArea], num7, 0.4f);
                }
                this.m_ChartOldMax[(int)profilerArea] = num7;
                profilerChart3.m_Data.AssignScale(new float[]
                {
                    1f / num7
                });
                ProfilerWindow.UpdateChartGrid(num7, profilerChart3.m_Data);
            }
            string notSupportedWarning = null;

            if (ProfilerDriver.isGPUProfilerBuggyOnDriver)
            {
                notSupportedWarning = "Graphics card driver returned invalid timing information. Please update to a newer version if available.";
            }
            else
            {
                if (!ProfilerDriver.isGPUProfilerSupported)
                {
                    notSupportedWarning = "GPU profiling is not supported by the graphics card driver. Please update to a newer version if available.";
                    if (Application.platform == RuntimePlatform.OSXEditor)
                    {
                        if (!ProfilerDriver.isGPUProfilerSupportedByOS)
                        {
                            notSupportedWarning = "GPU profiling requires Mac OS X 10.7 (Lion) and a capable video card. GPU profiling is currently not supported on mobile.";
                        }
                        else
                        {
                            notSupportedWarning = "GPU profiling is not supported by the graphics card driver (or it was disabled because of driver bugs).";
                        }
                    }
                }
            }
            this.m_Charts[1].m_Chart.m_NotSupportedWarning = notSupportedWarning;
        }