【UnityEditor编辑器扩展】遍历子节点,带中断实现

项目内,全局搜索预制体

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);
        /// 
        /// 遍历子节点用
        /// 
        /// 
        /// 
        /// 若return true,则中断
        static bool LoopChild(Transform tran, string fullPath,TransformCallback cb)
        {
            bool ret = cb(tran,fullPath);//先返回父节点,再返回子节点
            //if (ret == true) return true;
            for(int i=0;i

实例,调用方法

LoopChild(prefab.transform,"",(tran,fullPath) =>
{
};

 

你可能感兴趣的:(每天一点u3d,程序员瞎折腾)