Пример #1
0
        void OnEnable()
        {
#if UNITY_2018_1_OR_NEWER
            if (attachProfilerState == null)
            {
                attachProfilerState = ConnectionUtility.GetAttachToPlayerState(this);
            }
#endif
            EditorConnection.instance.Initialize();
            EditorConnection.instance.Register(UnityMemoryProfilerSupportKunClient.kMsgSendPlayerToEditor, OnMessageEvent);
        }
        private void OnEnable()
        {
            if (attachProfilerState == null)
            {
                attachProfilerState = ConnectionUtility.GetAttachToPlayerState(this);
            }
            UnityEditor.Networking.PlayerConnection.EditorConnection.instance.Initialize();
            UnityEditor.Networking.PlayerConnection.EditorConnection.instance.Register(UnityProfilerLiteKun.kMsgSendPlayerToEditor, OnMessageEvent);

            if (frameCountMax <= 0)
            {
                frameCountMax = 999999;
            }
        }
Пример #3
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;
        }