项目内,全局搜索预制体
var title = "";
var progress = 0;
var files = SearchFiles(Application.dataPath, new []{"*.prefab"});
EditorUtility.DisplayProgressBar(title, assetPath, ++progress / filesCount);
EditorUtility.ClearProgressBar();
遍历+中断(半实现)
delegate bool TransformCallback(Transform tran,string fullPath);
/// <summary>
/// 遍历子节点用
/// </summary>
/// <param name="tran"></param>
/// <param name="cb"></param>
/// <returns>若return true,则中断</returns>
static bool LoopChild(Transform tran, string fullPath,TransformCallback cb)
{
bool ret = cb(tran,fullPath);//先返回父节点,再返回子节点
//if (ret == true) return true;
for(int i=0;i<tran.childCount;i++)
{
var child = tran.GetChild(i);
ret = LoopChild(child,fullPath+"/" + child.name,cb);
//if (ret == true) return true;
}
return false;
}
实例,调用方法
LoopChild(prefab.transform,"",(tran,fullPath) =>
{
};