77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Threading;
|
|||
|
using UnityEditor;
|
|||
|
using UnityEngine;
|
|||
|
public static class AssetRefSearchTool
|
|||
|
{
|
|||
|
#if UNITY_EDITOR
|
|||
|
static string[] assetGUIDs;
|
|||
|
static string[] assetPaths;
|
|||
|
static string[] allAssetPaths;
|
|||
|
static Thread thread;
|
|||
|
|
|||
|
[MenuItem("<22><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>/<2F><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Projectѡ<74>еģ<D0B5>", false)]
|
|||
|
static void FindAssetRefMenu()
|
|||
|
{
|
|||
|
if (Selection.assetGUIDs.Length == 0)
|
|||
|
{
|
|||
|
Debug.Log("<22><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB>˲˵<CBB2>");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
assetGUIDs = Selection.assetGUIDs;
|
|||
|
|
|||
|
assetPaths = new string[assetGUIDs.Length];
|
|||
|
|
|||
|
for (int i = 0; i < assetGUIDs.Length; i++)
|
|||
|
{
|
|||
|
assetPaths[i] = AssetDatabase.GUIDToAssetPath(assetGUIDs[i]);
|
|||
|
}
|
|||
|
|
|||
|
allAssetPaths = AssetDatabase.GetAllAssetPaths();
|
|||
|
|
|||
|
thread = new Thread(new ThreadStart(FindAssetRef));
|
|||
|
thread.Start();
|
|||
|
}
|
|||
|
|
|||
|
static void FindAssetRef()
|
|||
|
{
|
|||
|
Debug.Log(string.Format("<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{0}<7D><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>", string.Join(",", assetPaths)));
|
|||
|
List<string> logInfo = new List<string>();
|
|||
|
string path;
|
|||
|
string log;
|
|||
|
for (int i = 0; i < allAssetPaths.Length; i++)
|
|||
|
{
|
|||
|
path = allAssetPaths[i];
|
|||
|
if (path.EndsWith(".prefab") || path.EndsWith(".unity"))
|
|||
|
{
|
|||
|
string content = File.ReadAllText(path);
|
|||
|
if (content == null)
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
for (int j = 0; j < assetGUIDs.Length; j++)
|
|||
|
{
|
|||
|
if (content.IndexOf(assetGUIDs[j]) > 0)
|
|||
|
{
|
|||
|
log = string.Format("{0} <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> {1}", path, assetPaths[j]);
|
|||
|
logInfo.Add(log);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < logInfo.Count; i++)
|
|||
|
{
|
|||
|
Debug.Log(logInfo[i]);
|
|||
|
}
|
|||
|
|
|||
|
Debug.Log("ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + logInfo.Count);
|
|||
|
|
|||
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
}
|
|||
|
#endif
|
|||
|
}
|