private void OrderByPriorityGUI() { for (int i = 0; i < m_TodoTypes.Length; i++) { switch (m_TodoTypes[i]) { case m_exclamation: { GUI.backgroundColor = Color.red; GUI.contentColor = Color.yellow; break; } case m_Question: { GUI.backgroundColor = Color.magenta; GUI.contentColor = Color.white; break; } case m_TODO: { GUI.backgroundColor = Color.cyan; GUI.contentColor = Color.white; break; } case m_X: { GUI.backgroundColor = Color.grey; GUI.contentColor = Color.white; break; } } m_priorityLevel = (MessagePriorityLevel)i; EditorGUILayout.Space(); EditorGUILayout.HelpBox($"{m_priorityLevel}", MessageType.None); foreach (GuiData item in m_TodoList) { if (item.MessageLevel == (MessagePriorityLevel)i) { if (GUILayout.Button($"{item.messageText} ({item.fileName} at line: {item.lineNumber})", EditorStyles.miniTextField)) { AssetDatabase.OpenAsset(FromRelativePathToInstanceID(item.path), item.lineNumber); } } } } }
private static void LookThroughScripts() { //replace this Dictionary <string, string> lookUp = new Dictionary <string, string>(); string[] path = Directory.GetFiles($"{GetProjectFolder()}Assets\\", $"*{m_fileEnd}", SearchOption.AllDirectories); for (int i = 0; i < path.Length; i++) { string _filepath = path[i]; if (_filepath.EndsWith(m_fileEnd)) { using (StreamReader sr = new StreamReader(_filepath)) { lookUp.Add(_filepath, sr.ReadToEnd()); } } } foreach (string script in lookUp.Values) { string _sub = string.Empty; int _lineCount = 1; foreach (string _todoType in m_TodoTypes) { _sub = script; while (_sub.Contains(_todoType)) { int _start = _sub.IndexOf(_todoType) + _todoType.Length; int _end = _sub.Substring(_start).IndexOf(m_Newline); if (_end < 0) { _end = 0; } //checks if its empty if (_sub.Substring(_start, _end) == "\";") { _sub = _sub.Substring(_start + _end); } else { //count line numbers for (int j = 0; j < _start + _end; j++) { if ($"{_sub[j]}{_sub[j + 1]}" == m_Newline) { _lineCount++; } } switch (_todoType) { case m_exclamation: { m_priorityLevel = MessagePriorityLevel.High; break; } case m_TODO: { m_priorityLevel = MessagePriorityLevel.Normal; break; } case m_Question: { m_priorityLevel = MessagePriorityLevel.Question; break; } case m_X: { m_priorityLevel = MessagePriorityLevel.Low; break; } default: { Debug.Log("something went wrong... " + _todoType); break; } } GuiData _data = new GuiData { MessageLevel = m_priorityLevel, messageText = (_end > 1 ? _sub.Substring(_start, _end) : _sub.Substring(_start)), lineNumber = _lineCount, path = ExtentionFunctions.GetKeyByValueInput(lookUp, script), }; _data.fileName = GetFileName(_data.path); m_TodoList.Add(_data); _sub = _sub.Substring(_start + _end); } } } } if (EditorPrefs.GetBool(pref_Show_DebugLog)) { Debug.Log("Finished looking through the scripts"); } m_buttonContext = m_refresh; }