{"id":1977,"date":"2017-12-28T15:33:51","date_gmt":"2017-12-28T07:33:51","guid":{"rendered":"http:\/\/www.u3d8.com\/?p=1977"},"modified":"2019-12-28T15:36:45","modified_gmt":"2019-12-28T07:36:45","slug":"%e6%9f%a5%e6%89%be%e8%b5%84%e6%ba%90%e5%93%aa%e9%87%8c%e8%a2%ab%e5%bc%95%e7%94%a8","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=1977","title":{"rendered":"\u67e5\u627e\u8d44\u6e90\u54ea\u91cc\u88ab\u5f15\u7528"},"content":{"rendered":"\n<p>\u8f6c\u81ea\uff1a<a href=\"http:\/\/www.xuanyusong.com\/archives\/4207\">http:\/\/www.xuanyusong.com\/archives\/4207<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using UnityEngine;\nusing System.Collections;\nusing UnityEditor;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Collections.Generic;\n\npublic class FindReferences\n{\n\n    [MenuItem(\"Assets\/Find References\", false, 10)]\n    static private void Find()\n    {\n        EditorSettings.serializationMode = SerializationMode.ForceText;\n        string path = AssetDatabase.GetAssetPath(Selection.activeObject);\n        if (!string.IsNullOrEmpty(path))\n        {\n            string guid = AssetDatabase.AssetPathToGUID(path);\n            List&lt;string> withoutExtensions = new List&lt;string>() { \".prefab\"\/*, \".unity\", \".mat\", \".asset\"*\/ };\n            string[] files = Directory.GetFiles(Application.dataPath, \"*.*\", SearchOption.AllDirectories)\n                .Where(s => withoutExtensions.Contains(Path.GetExtension(s).ToLower())).ToArray();\n            int startIndex = 0;\n\n            EditorApplication.update = delegate ()\n            {\n                string file = files[startIndex];\n\n                bool isCancel = EditorUtility.DisplayCancelableProgressBar(\"\u5339\u914d\u8d44\u6e90\u4e2d\", file, (float)startIndex \/ (float)files.Length);\n\n                if (Regex.IsMatch(File.ReadAllText(file), guid))\n                {\n                    Debug.Log(file, AssetDatabase.LoadAssetAtPath&lt;Object>(GetRelativeAssetsPath(file)));\n                }\n\n                startIndex++;\n                if (isCancel || startIndex >= files.Length)\n                {\n                    EditorUtility.ClearProgressBar();\n                    EditorApplication.update = null;\n                    startIndex = 0;\n                    Debug.Log(\"\u5339\u914d\u7ed3\u675f\");\n                }\n\n            };\n        }\n    }\n\n    [MenuItem(\"Assets\/Find References\", true)]\n    static private bool VFind()\n    {\n        string path = AssetDatabase.GetAssetPath(Selection.activeObject);\n        return (!string.IsNullOrEmpty(path));\n    }\n\n    static private string GetRelativeAssetsPath(string path)\n    {\n        return \"Assets\" + Path.GetFullPath(path).Replace(Path.GetFullPath(Application.dataPath), \"\").Replace('\\\\', '\/');\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u81ea\uff1ahttp:\/\/www.xuanyusong.com\/archives\/42 &hellip; <a href=\"http:\/\/www.u3d8.com\/?p=1977\">\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],"tags":[],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/1977"}],"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=1977"}],"version-history":[{"count":1,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/1977\/revisions"}],"predecessor-version":[{"id":1978,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/1977\/revisions\/1978"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1977"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}