Ejemplo n.º 1
0
 private void OpenEditorToEntry(TODOEntry entry, int lineNum = -1)
 {
     UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(entry.file, typeof(TextAsset));
     if (obj != null)
     {
         AssetDatabase.OpenAsset(obj, (lineNum != -1) ? lineNum : entry.line);
     }
 }
Ejemplo n.º 2
0
 private void ScanTODOList()
 {
     try
     {
         DirectoryInfo dirInfo   = new DirectoryInfo(Application.dataPath + "/");
         FileInfo[]    fileInfos = dirInfo.GetFiles("*.cs", SearchOption.AllDirectories);
         if (fileInfos != null)
         {
             for (int i = 0; i < fileInfos.Length; ++i)
             {
                 FileInfo fi = fileInfos[i];
                 using (StreamReader reader = fi.OpenText())
                 {
                     int    lineNum = 0;
                     string line    = null;
                     while ((line = reader.ReadLine()) != null)
                     {
                         ++lineNum;
                         Match result = todoMatchPattern.Match(line);
                         if (result.Success)
                         {
                             string    text  = result.Groups[2].Value;
                             string    file  = fi.FullName.Replace("\\", "/").Replace(Application.dataPath, "Assets");
                             TODOEntry entry = new TODOEntry {
                                 text  = text,
                                 file  = file,
                                 line  = lineNum,
                                 whole = string.Format("{0}\n\n(at {1}:{2})", line.Trim(), file, lineNum),
                             };
                             currentEntries.Add(entry);
                             // @TODO: 高亮被命中的字符串
                             if (searchPattern == null)
                             {
                                 currentDisplayEntries.Add(entry);
                             }
                             else if (IsTODOEntryMatch(searchPattern, line))
                             {
                                 currentDisplayEntries.Add(entry);
                                 ++matchCount;
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Debug.LogException(ex);
     }
 }
Ejemplo n.º 3
0
 private void ReFetchEntryDisplayList()
 {
     currentDisplayEntries.Clear();
     matchCount = 0;
     for (int i = 0; i < currentEntries.Count; ++i)
     {
         TODOEntry entry = currentEntries[i];
         // @TODO: 高亮被命中的字符串
         if (searchPattern == null)
         {
             currentDisplayEntries.Add(entry);
         }
         else if (IsTODOEntryMatch(searchPattern, entry.whole))
         {
             currentDisplayEntries.Add(entry);
             ++matchCount;
         }
     }
 }
Ejemplo n.º 4
0
    private void DrawDetail()
    {
        Event current = Event.current;

        GUILayout.Space(1f);
        detailScrollPosition = EditorGUILayout.BeginScrollView(detailScrollPosition);
        TODOEntry entry = (currentDisplayEntries == null || currentSelectedEntryIndex < 0 || currentDisplayEntries.Count <= currentSelectedEntryIndex)
                        ? null : currentDisplayEntries[currentSelectedEntryIndex];

        ContentConstants.detailGUIContent.text = entry != null ? entry.whole : string.Empty;
        float minHeight = StyleConstants.MessageStyle.CalcHeight(ContentConstants.detailGUIContent, position.width);

        if (selectChanged)
        {
            // 当选中的条目发生变化的时候,要将当前的选择状态取消掉
            GUIUtility.hotControl      = 0;
            GUIUtility.keyboardControl = 0;
        }
        EditorGUILayout.SelectableLabel(ContentConstants.detailGUIContent.text, StyleConstants.MessageStyle, GUILayout.ExpandWidth(true), GUILayout.Height(minHeight));

        EditorGUILayout.EndScrollView();
    }