/// <summary>
        /// 序列化结束时会被调用,因此静态数据的赋值需要放在这里执行
        /// </summary>
        private void OnEnable()
        {
            logLineCount    = PlayerPrefs.GetInt(LogLineCountPref, 1);
            collapse        = PlayerPrefs.GetInt(CollapsePref, 0) == 1;
            clearOnPlay     = PlayerPrefs.GetInt(ClearOnPlayPref, 0) == 1;
            errorPause      = PlayerPrefs.GetInt(ErrorPausePref, 0) == 1;
            autoScroll      = PlayerPrefs.GetInt(AutoScrollPref, 0) == 1;
            showlogAnalysis = PlayerPrefs.GetInt(ShowAnalysisPref, 0) == 1;

            searchWithRegex = PlayerPrefs.GetInt(SearchWithRegexPref, 0) == 1;
            showTime        = PlayerPrefs.GetInt(ShowTimePref, 0) == 1;
            showLog         = PlayerPrefs.GetInt(ShowLogPref, 0) == 1;
            showWarning     = PlayerPrefs.GetInt(ShowWarningPref, 0) == 1;
            showError       = PlayerPrefs.GetInt(ShowErrorPref, 0) == 1;

            logFilter.showLog     = showLog;
            logFilter.showWarning = showWarning;
            logFilter.showError   = showError;
            logFilter.collapse    = collapse;
            logFilter.searchText  = searchText;
            shouldUpdateLogFilter = true;

            editorManager.OnEnable();
            analysisDataTreeView = new UnityDebugViewerAnalysisDataTreeView(this.editorManager.activeEditor.analysisDataManager.root);

#if UNITY_2017_2_OR_NEWER
            EditorApplication.playModeStateChanged += PlayModeStateChangeHandler;
#else
            EditorApplication.playmodeStateChanged += PlayModeStateChangeHandler;
#endif
        }
        private void DrawMenuBar()
        {
            menuBarRect = new Rect(0, 0, position.width, menuBarHeight);

            GUILayout.BeginArea(menuBarRect, EditorStyles.toolbar);
            {
                GUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button(new GUIContent("Clear"), EditorStyles.toolbarButton, GUILayout.Width(40)))
                    {
                        this.editorManager.activeEditor.Clear();
                    }

                    GUILayout.Space(5);

                    EditorGUI.BeginChangeCheck();
                    collapse = GUILayout.Toggle(collapse, new GUIContent("Collapse"), EditorStyles.toolbarButton);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.logFilter.collapse    = collapse;
                        this.shouldUpdateLogFilter = true;
                        PlayerPrefs.SetInt(CollapsePref, collapse ? 1 : 0);
                    }

                    EditorGUI.BeginChangeCheck();
                    clearOnPlay = GUILayout.Toggle(clearOnPlay, new GUIContent("Clear On Play"), EditorStyles.toolbarButton);
                    errorPause  = GUILayout.Toggle(errorPause, new GUIContent("Error Pause"), EditorStyles.toolbarButton);
                    autoScroll  = GUILayout.Toggle(autoScroll, new GUIContent("Auto Scroll"), EditorStyles.toolbarButton);

                    GUILayout.Space(5);

                    showlogAnalysis = GUILayout.Toggle(showlogAnalysis, new GUIContent("Show Analysis"), EditorStyles.toolbarButton);

                    if (EditorGUI.EndChangeCheck())
                    {
                        PlayerPrefs.SetInt(ClearOnPlayPref, clearOnPlay ? 1 : 0);
                        PlayerPrefs.SetInt(ErrorPausePref, errorPause ? 1 : 0);
                        PlayerPrefs.SetInt(AutoScrollPref, autoScroll ? 1 : 0);
                        PlayerPrefs.SetInt(ShowAnalysisPref, showlogAnalysis ? 1 : 0);
                    }

                    GUILayout.Space(5);

                    Vector2 size = EditorStyles.toolbarPopup.CalcSize(new GUIContent(this.editorManager.activeMode));
                    EditorGUI.BeginChangeCheck();
                    this.editorManager.activeModeIndex = EditorGUILayout.Popup(this.editorManager.activeModeIndex, this.editorManager.modeArray, EditorStyles.toolbarPopup, GUILayout.Width(size.x));
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.analysisDataTreeView  = new UnityDebugViewerAnalysisDataTreeView(this.editorManager.activeEditor.analysisDataManager.root);
                        this.shouldUpdateLogFilter = true;
                    }

                    this.editorManager.activeEditor.OnGUI();

                    GUILayout.FlexibleSpace();


                    string tempSearchText = UnityDebugViewerWindowUtility.CopyPasteTextField(this.searchText, UnityDebugViewerWindowStyleUtility.toolbarSearchTextStyle, GUILayout.MinWidth(180f), GUILayout.MaxWidth(300f));
                    if (tempSearchText.Equals(this.searchText) == false)
                    {
                        this.clearSearchText = string.IsNullOrEmpty(tempSearchText) && string.IsNullOrEmpty(this.searchText) == false;

                        this.searchText            = tempSearchText;
                        this.logFilter.searchText  = this.searchText;
                        this.shouldUpdateLogFilter = true;
                    }

                    string logNum     = this.editorManager.activeEditor.logNum.ToString();
                    string warningNum = this.editorManager.activeEditor.warningNum.ToString();
                    string errorNum   = this.editorManager.activeEditor.errorNum.ToString();

                    EditorGUI.BeginChangeCheck();
                    searchWithRegex = GUILayout.Toggle(searchWithRegex, new GUIContent("Regex"), EditorStyles.toolbarButton);
                    showTime        = GUILayout.Toggle(showTime, new GUIContent("Time"), EditorStyles.toolbarButton);
                    showLog         = GUILayout.Toggle(showLog, new GUIContent(logNum, UnityDebugViewerWindowStyleUtility.infoIconSmallTexture), EditorStyles.toolbarButton);
                    showWarning     = GUILayout.Toggle(showWarning, new GUIContent(warningNum, UnityDebugViewerWindowStyleUtility.warningIconSmallTexture), EditorStyles.toolbarButton);
                    showError       = GUILayout.Toggle(showError, new GUIContent(errorNum, UnityDebugViewerWindowStyleUtility.errorIconSmallTexture), EditorStyles.toolbarButton);
                    if (EditorGUI.EndChangeCheck())
                    {
                        PlayerPrefs.SetInt(SearchWithRegexPref, searchWithRegex ? 1 : 0);
                        PlayerPrefs.SetInt(ShowTimePref, showTime ? 1 : 0);
                        PlayerPrefs.SetInt(ShowLogPref, showLog ? 1 : 0);
                        PlayerPrefs.SetInt(ShowWarningPref, showWarning ? 1 : 0);
                        PlayerPrefs.SetInt(ShowErrorPref, showError ? 1 : 0);

                        this.logFilter.searchWithRegex = searchWithRegex;
                        this.logFilter.showTime        = showTime;
                        this.logFilter.showLog         = showLog;
                        this.logFilter.showWarning     = showWarning;
                        this.logFilter.showError       = showError;
                        this.shouldUpdateLogFilter     = true;
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndArea();
        }