/// <summary> /// Builds the asset bundles update A. /// </summary> public static void buildAssetBundlesUpdateAB() { EditorUtility.DisplayProgressBar("Generate FileList", "loading bundle manifest", 1 / 2); AssetDatabase.Refresh(); string readPath = EditorUtils.GetFileStreamingOutAssetsPath(); // 读取Streaming目录 var u3dList = EditorUtils.getAllChildFiles(readPath, @"\.meta$|\.manifest$|\.DS_Store$|\.u$", null, false); List <string> assets = new List <string> (); foreach (var s in u3dList) { string ab = EditorUtils.GetAssetPath(s); //s.Replace(readPath, "").Replace("/", "").Replace("\\", ""); assets.Add(ab); } readPath = new System.IO.DirectoryInfo(EditorUtils.GetLuaBytesResourcesPath()).FullName; // 读取lua 目录 u3dList = EditorUtils.getAllChildFiles(readPath, @"\.bytes$", null); foreach (var s in u3dList) { string ab = EditorUtils.GetAssetPath(s); //s.Replace(readPath, "").Replace("/", "").Replace("\\", ""); assets.Add(ab); } EditorUtility.ClearProgressBar(); CUtils.DebugCastTime("Time Generate FileList End"); Debug.Log("all assetbundle count = " + assets.Count); BuildScript.GenerateAssetBundlesUpdateFile(assets.ToArray()); CUtils.DebugCastTime("Time GenerateAssetBundlesUpdateFile End"); }
//select objects contains folder file public static UnityEngine.Object[] SelectObjects(params System.Type[] args) //System.Type[] filter = null) { if (args.Length == 0) { args = new System.Type[] { typeof(UnityEngine.Object) } } ; System.Func <Object, bool> checkType = (Object s) => { foreach (System.Type t in args) { // Debug.LogFormat("{0}={1},is={2}",s.GetType(),t,s.GetType().IsSubclassOf(t)); if (s.GetType().IsSubclassOf(t) || s.GetType().Equals(t)) { return(true); } } return(false); }; List <UnityEngine.Object> re = new List <UnityEngine.Object> (); Object[] selection = UnityEditor.Selection.objects; string path = string.Empty; foreach (Object s in selection) { if (s is DefaultAsset && (path = AssetDatabase.GetAssetPath(s)) != null && Directory.Exists(path)) { var import = AssetImporter.GetAtPath(path); if (!string.IsNullOrEmpty(import.assetBundleName)) { re.Add(s); } else { var allchildren = getAllChildFiles(path, @"\.meta$|\.manifest$|\.DS_Store$|\.u$", null, false); foreach (var f in allchildren) { var cpath = EditorUtils.GetAssetPath(f); // Debug.Log(cpath); var obj = AssetDatabase.LoadAssetAtPath(cpath, typeof(Object)); if (checkType(obj)) { re.Add(obj); } } } } else if (checkType(s)) { re.Add(s); } } return(re.ToArray()); } }