输出Assets文件下的Scripts文件内的所有代码行数
using System.IO;
using UnityEditor;
using UnityEngine;
public class CodeTotal
{
[MenuItem("输出总代码行数/输出")]
private static void PrintTotalLine()
{
string[] fileName = AssetDatabase.FindAssets("t:Script", new string[] { "Assets/Scripts" });
int totalLine = 0;
foreach (var temp in fileName)
{
int nowLine = 0;
string path = AssetDatabase.GUIDToAssetPath(temp);
StreamReader sr = new StreamReader(path);
while (sr.ReadLine() != null)
{
nowLine++;
}
totalLine += nowLine;
}
Debug.Log(totalLine);
}
}