// 在scrollview里填充log,unity m_upperPanelScroll = GUILayout.BeginScrollView(m_upperPanelScroll); for (int i = 0; i < m_logItems.Count; i++) { if (m_logTypeForUnshow.Contains(m_logItems[i].GetLogType)) { continue; }
// 画的时候,顺便接受item的点击的结果 if (DrawLogBox(m_logItems[i].LogInfo, m_logItems[i].GetLogType, i % 2 == 0, m_logItems[i].IsSelected)) { if (null != m_selectedLogItem) { if (m_logItems[i] == m_selectedLogItem) { // click a some one, open code // JumpToCurrentLogPos(); // 跳转到你点击的Log的顶部的代码文件(如果可以 } else { m_selectedLogItem.IsSelected = false; m_selectedLogItem = m_logItems[i]; m_selectedLogItem.IsSelected = true; } } else { m_selectedLogItem = m_logItems[i]; m_selectedLogItem.IsSelected = true; } // 准备刷新 GUI.changed = true; } }
GUILayout.EndScrollView(); GUILayout.EndArea(); }
privatevoidOnGUI() { // ..... if (GUI.changed) { Repaint(); } }
logDetailMutiLine = logDetail.Split('\n'); for (int i = 0; i < logDetailMutiLine.Length; i++) { // Regex match 'at xxx' Match matches = Regex.Match(logDetailMutiLine[i], @"\(at (.+)\)", RegexOptions.Multiline);
if (matches.Success) { while (matches.Success) { pathline = matches.Groups[1].Value; if (pathline.Contains(tempCase)) { int splitIndex = pathline.LastIndexOf(":"); path = pathline.Substring(0, splitIndex); line = Convert.ToInt32(pathline.Substring(splitIndex + 1)); string fullpath = Application.dataPath.Substring(0, Application.dataPath.LastIndexOf("Assets")); fullpath = fullpath + path; splitwa = logDetailMutiLine[i].LastIndexOf("("); logDetailMutiLine[i] = logDetailMutiLine[i].Substring(0, splitwa);
m_infoIcon = EditorGUIUtility.Load("icons/console.infoicon.png") as Texture2D; m_infoIconSmall = EditorGUIUtility.Load("icons/console.infoicon.sml.png") as Texture2D; m_warningIcon = EditorGUIUtility.Load("icons/console.warnicon.png") as Texture2D; m_warningIconSmall = EditorGUIUtility.Load("icons/console.warnicon.sml.png") as Texture2D; m_errorIcon = EditorGUIUtility.Load("icons/console.erroricon.png") as Texture2D; m_errorIconSmall = EditorGUIUtility.Load("icons/console.erroricon.sml.png") as Texture2D;
m_resizerStyle = new GUIStyle();
m_panelStyle = new GUIStyle(); m_panelStyle.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/projectbrowsericonareabg.png") as Texture2D; // 这行是同事告诉我的,但是不知道为什么不管用,直接用会有空引用报错,要在GUI里用 // m_panelStyle.normal.background = GUI.skin.window.normal.background;
m_boxItemStyle = new GUIStyle(); m_boxItemStyle.normal.textColor = new Color(0.7f, 0.7f, 0.7f);
m_boxBgOdd = EditorGUIUtility.Load("builtin skins/darkskin/images/cn entrybackodd.png") as Texture2D; m_boxBgEven = EditorGUIUtility.Load("builtin skins/darkskin/images/cnentrybackeven.png") as Texture2D; m_boxBgSelected = EditorGUIUtility.Load("builtin skins/darkskin/images/menuitemhover.png") as Texture2D;
m_textAreaStyle = new GUIStyle(); m_textAreaStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f); m_textAreaStyle.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/projectbrowsericonareabg.png") as Texture2D;