Beispiel #1
0
        public virtual void UpdateData(int firstEmptyFrame, int firstFrame, int frameCount)
        {
            // Clear the data available buffer prior to iterating over chart series.
            if (m_Series.Length > 0)
            {
                m_Data.ClearDataAvailableBuffer();
            }

            // Iterate over all chart series pulling counter data.
            float totalMaxValue = 1;

            for (int i = 0, count = m_Series.Length; i < count; ++i)
            {
                float maxValue;
                if (usesCounters)
                {
                    // Retrieve counter values by category name & counter name.
                    ProfilerDriver.GetCounterValuesWithAvailabilityBatchByCategory(m_Series[i].category, m_Series[i].name, firstEmptyFrame, 1.0f, m_Series[i].yValues, m_Data.dataAvailable, out maxValue);
                }
                else
                {
                    // Retrieve counter values by area & counter name.
                    ProfilerDriver.GetCounterValuesWithAvailabilityBatch(m_Area, m_Series[i].name, firstEmptyFrame, 1.0f, m_Series[i].yValues, m_Data.dataAvailable, out maxValue);
                }

                m_Series[i].yScale = m_DataScale;
                maxValue          *= m_DataScale;

                // Minimum size so we don't generate nans during drawing
                maxValue = Mathf.Max(maxValue, 0.0001F);

                if (maxValue > totalMaxValue)
                {
                    totalMaxValue = maxValue;
                }

                if (m_Type == ProfilerModuleChartType.Line)
                {
                    // Scale line charts so they never hit the top. Scale them slightly differently for each line
                    // so that in "no stuff changing" case they will not end up being exactly the same.
                    maxValue *= (1.05f + i * 0.05f);
                    m_Series[i].rangeAxis = new Vector2(0f, maxValue);
                }
            }

            if (m_SharedScale && m_Type == ProfilerModuleChartType.Line)
            {
                // For some charts, every line is scaled individually, so every data series gets their own range based on their own max scale.
                // For charts that share their scale (like the Networking charts) all series get adjusted to the total max of the chart.
                for (int i = 0, count = m_Series.Length; i < count; ++i)
                {
                    m_Series[i].rangeAxis = new Vector2(0f, (1.05f + i * 0.05f) * totalMaxValue);
                }
                m_Data.maxValue = totalMaxValue;
            }
            m_Data.Assign(m_Series, firstEmptyFrame, firstFrame);
        }