Exemplo n.º 1
0
        //--------------------------------------
        // Static
        //--------------------------------------


        public static void SaveConsoleWindowState(UCL_ConsoleWindowState state)
        {
            string json = JsonUtility.ToJson(state);

            EditorPrefs.SetString(CONSOLE_WINDOW_STATE_SETTINGS, json);

            m_onSettingsUpdated.Invoke();
        }
        //--------------------------------------
        // Initialization
        //--------------------------------------


        private void OnEnable()
        {
            titleContent.text = "Console";
            if (!EditorGUIUtility.isProSkin)
            {
                titleContent.image = Resources.Load("console/logger_window_icon") as Texture2D;
            }
            else
            {
                titleContent.image = Resources.Load("console/logger_window_icon_pro") as Texture2D;
            }

            m_lastLogsCount = 0;
            m_toolbarStyle  = null;


            m_state = UCL_Settings.ConsoleWindowState;


            if (m_rootViewSate == null)
            {
                m_rootViewSate = new SA_SplitViewState();
                m_logsView     = new UCL_LogsView();
                m_stackView    = new UCL_StackView();
            }

            m_rootView             = new SA_SplitView(m_rootViewSate);
            m_rootView.Orientation = Orientation.Vertical;

            m_rootView.Panel1.MinSize   = 150;
            m_rootView.Panel1.StartSize = 300;
            m_rootView.Panel1.SetView(m_logsView);

            m_rootView.Panel2.MinSize = 150;
            m_rootView.Panel2.SetView(m_stackView);
            m_rootView.SplitterSize = 1.0f;


            //To keep logs view up to date
            EditorApplication.update += OnEditorUpdate;
            Application.logMessageReceivedThreaded += LogReceiveHandler;


            UCL_Settings.OnSettingsUpdated.AddSafeListener(this, RebuildLogsView);
            m_logsView.OnEnable();
            m_stackView.OnEnable();
        }
        private void RebuildLogsView()
        {
            m_state = UCL_Settings.ConsoleWindowState;

            var logs           = UCL_LogEntries.GetLog();
            var preFiltredLogs = new List <UCL_LogInfo>();

            foreach (var log in logs)
            {
                var tag = UCL_Settings.Instance.GetTag(log.TagName);
                if (m_state.IsTagEnabled(tag))
                {
                    preFiltredLogs.Add(log);
                }
            }

            m_logsView.RebuildLogsView(preFiltredLogs);

            m_tagsMessagesCount = new Dictionary <string, int>();
            foreach (var log in logs)
            {
                IncrementMessagesCountForTag(log.TagName);
            }
        }
 public override void OnLayoutEnable()
 {
     m_state = UCL_Settings.ConsoleWindowState;
 }