{"id":1970,"date":"2019-05-03T19:32:23","date_gmt":"2019-05-03T11:32:23","guid":{"rendered":"http:\/\/www.u3d8.com\/?p=1970"},"modified":"2019-11-18T19:44:42","modified_gmt":"2019-11-18T11:44:42","slug":"%e6%9f%a5%e6%89%be%e4%bb%a3%e7%a0%81%e9%87%8c%e7%9a%84%e4%b8%ad%e6%96%87%e4%b8%94%e6%8e%92%e9%99%a4%e6%b3%a8%e9%87%8a","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=1970","title":{"rendered":"\u67e5\u627e\u4ee3\u7801\u91cc\u7684\u4e2d\u6587\u4e14\u6392\u9664\u6ce8\u91ca"},"content":{"rendered":"\n<p>\u5f88\u591a\u9879\u76ee\u521d\u671f\uff0c\u662f\u6ca1\u6709\u8003\u8651\u591a\u8bed\u8a00\u6216\u8005\u591a\u8bed\u8a00\u6846\u67b6\u7684\u60c5\u51b5\u3002<\/p>\n\n\n\n<p>\u800c\u4e14\u4e3a\u4e86\u65b9\u4fbf\u5e73\u65f6\u67e5\u770b\u3001\u8c03\u8bd5\uff0c\u6211\u4eec\u90fd\u4f1a\u4f7f\u7528\u4e2d\u6587\u4f5c\u4e3a\u9ed8\u8ba4\u8bed\u8a00\u5728\u4ee3\u7801\u4e2d\u8d4b\u503c\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u4f1a\u9020\u6210\u9879\u76ee\u540e\u671f\uff0c\u4ee3\u7801\u91cc\u7684\u4e2d\u6587\u5b57\u7b26\u592a\u591a\uff0c\u505a\u591a\u8bed\u8a00\u7684\u65f6\u5019\uff0c\u8981\u6328\u4e2a\u811a\u672c\u53bb\u627e\uff0c\u975e\u5e38\u9ebb\u70e6\u3002<\/p>\n\n\n\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u7e41\u7410\u95ee\u9898\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u7f16\u8f91\u5668\u6765\u5feb\u901f\u7b5b\u9009\u4e2d\u6587<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img title=\"\u67e5\u627e\u4ee3\u7801\u91cc\u7684\u4e2d\u6587\u4e14\u6392\u9664\u6ce8\u91ca - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u67e5\u627e\u4ee3\u7801\u91cc\u7684\u4e2d\u6587\u4e14\u6392\u9664\u6ce8\u91ca - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" loading=\"lazy\" width=\"416\" height=\"139\" src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2019\/11\/QQ\u622a\u56fe20191118193410.jpg\" alt=\"\" class=\"wp-image-1971\" srcset=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2019\/11\/QQ\u622a\u56fe20191118193410.jpg 416w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2019\/11\/QQ\u622a\u56fe20191118193410-300x100.jpg 300w\" sizes=\"(max-width: 416px) 100vw, 416px\" \/><\/figure><\/div>\n\n\n\n<p>\u4e0a\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using UnityEngine;\nusing UnityEditor;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Collections;\nusing System.Text.RegularExpressions;\nusing System.Text;\n\npublic class FindChineseTool : MonoBehaviour\n{\n    [MenuItem(\"Tools\/\u67e5\u627e\u4ee3\u7801\u4e2d\u6587\")]\n    public static void Pack()\n    {\n        Rect wr = new Rect(300, 400, 400, 100);\n        FindChineseWindow window = (FindChineseWindow)EditorWindow.GetWindowWithRect(typeof(FindChineseWindow), wr, true, \"\u67e5\u627e\u9879\u76ee\u4e2d\u7684\u4e2d\u6587\u5b57\u7b26\");\n        window.Show();\n    }\n}\n\npublic class FindChineseWindow : EditorWindow\n{\n    private ArrayList csList = new ArrayList();\n    private int eachFrameFind = 4;\n    private int currentIndex = 0;\n    private bool isBeginUpdate = false;\n    private string outputText;\n    public string filePath = \"\/Scripts\";\n    private string strForShader = \"\";\n\n\n    private void GetAllFile(DirectoryInfo dir)\n    {\n        FileInfo[] allFile = dir.GetFiles();\n        foreach (FileInfo fi in allFile)\n        {\n            if (fi.DirectoryName.Contains(\"FindChineseTool\"))\/\/\u6392\u9664\u6307\u5b9a\u540d\u79f0\u7684\u4ee3\u7801\n                continue;\n            if (fi.FullName.IndexOf(\".meta\") == -1 &amp;&amp; fi.FullName.IndexOf(\".cs\") != -1)\n            {\n                csList.Add(fi.DirectoryName + \"\/\"  + fi.Name);\n            }\n        }\n        DirectoryInfo[] allDir = dir.GetDirectories();\n        foreach (DirectoryInfo d in allDir)\n        {\n            GetAllFile(d);\n        }\n    }\n    public void OnGUI()\n    {\n        filePath = EditorGUILayout.TextField(\"\u8def\u5f84\uff1a\", filePath);\n\n        EditorGUILayout.Space();\n        EditorGUILayout.Space();\n\n        if (GUILayout.Button(\"\u5f00\u59cb\u904d\u5386\u76ee\u5f55\"))\n        {\n            csList.Clear();\n            DirectoryInfo d = new DirectoryInfo(Application.dataPath + filePath);\n            GetAllFile(d);\n            GetAllFile(d);\n            outputText = \"\u6e38\u620f\u5185\u4ee3\u7801\u6587\u4ef6\u7684\u6570\u91cf\uff1a\" + csList.Count;\n            isBeginUpdate = true;\n            outputText = \"\u5f00\u59cb\u904d\u5386\u9879\u76ee\";\n        }\n        GUILayout.Label(outputText, EditorStyles.boldLabel);\n    }\n    void Update()\n    {\n        if (isBeginUpdate &amp;&amp; currentIndex &lt; csList.Count)\n        {\n            int count = (csList.Count - currentIndex) > eachFrameFind ? eachFrameFind : (csList.Count - currentIndex);\n            for (int i = 0; i &lt; count; i++)\n            {\n                string url = csList[currentIndex].ToString();\n                currentIndex = currentIndex + 1;\n                url = url.Replace(\"\\\\\", \"\/\");\n                printChinese(url);\n            }\n            if (currentIndex >= csList.Count)\n            {\n                isBeginUpdate = false;\n                currentIndex = 0;\n                outputText = \"\u904d\u5386\u7ed3\u675f\uff0c\u603b\u5171\" + csList.Count;\n            }\n        }\n    }\n    private bool HasChinese(string str)\n    {\n        return Regex.IsMatch(str, @\"[\\u4e00-\\u9fa5]\");\n    }\n    private Regex regex = new Regex(\"\\\"[^\\\"]*\\\"\");\n    private void printChinese(string path)\n    {\n        if (File.Exists(path))\n        {\n            string[] fileContents = File.ReadAllLines(path, Encoding.Default);\n            int count = fileContents.Length;\n            for (int i = 0; i &lt; count; i++)\n            {\n                string printStr = fileContents[i].Trim();\n                if (printStr.IndexOf(\"\/\/\") == 0)  \/\/\u8bf4\u660e\u662f\u6ce8\u91ca\n                    continue;\n                if (printStr.IndexOf(\"Debug.Log\") == 0)  \/\/\u8bf4\u660e\u662f\u6ce8\u91ca\n                    continue;\n                \/\/if (printStr.IndexOf(\"ALog.Log\") == 0)  \/\/\u8bf4\u660e\u662f\u6ce8\u91ca\n                \/\/    continue;\n                MatchCollection matches = regex.Matches(printStr);\n                foreach (Match match in matches)\n                {\n                    if (HasChinese(match.Value))\n                    {\n                        string[] fullPath = path.Split('\/');\n                        path = fullPath[fullPath.Length - 1];\n                        Debug.Log(\"\u8def\u5f84:\"+path + \" \u884c\u6570:\" + i + \" \u5185\u5bb9:\" + printStr);\n                        break;\n                    }\n                }\n            }\n            fileContents = null;\n        }\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u591a\u9879\u76ee\u521d\u671f\uff0c\u662f\u6ca1\u6709\u8003\u8651\u591a\u8bed\u8a00\u6216\u8005\u591a\u8bed\u8a00\u6846\u67b6\u7684\u60c5\u51b5\u3002 \u800c\u4e14\u4e3a\u4e86\u65b9\u4fbf\u5e73\u65f6\u67e5\u770b\u3001\u8c03\u8bd5 &hellip; <a href=\"http:\/\/www.u3d8.com\/?p=1970\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[297,23],"tags":[396],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/1970"}],"collection":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1970"}],"version-history":[{"count":1,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/1970\/revisions"}],"predecessor-version":[{"id":1972,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/1970\/revisions\/1972"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1970"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}