Beispiel #1
0
        private static void CollectABInFolder(string folderPath, Dictionary <string, int> builderData)
        {
            if (folderPath == null)
            {
                Log.I("Folder Path Is Null.");
                return;
            }

            string workPath = EditorUtils.AssetsPath2ABSPath(folderPath);

            var filePaths = Directory.GetFiles(workPath);

            for (int i = 0; i < filePaths.Length; ++i)
            {
                if (!AssetFileFilter.IsAsset(filePaths[i]))
                {
                    continue;
                }

                string fileName = Path.GetFileName(filePaths[i]);

                string fullFileName = string.Format("{0}/{1}", folderPath, fileName);

                AssetImporter ai = AssetImporter.GetAtPath(fullFileName);
                if (ai == null)
                {
                    Log.I("Not Find Asset:" + fullFileName);
                    continue;
                }
                else if (!string.IsNullOrEmpty(ai.assetBundleName))
                {
                    RecordNewAB(ai.assetBundleName, builderData);
                }
            }

            //递归处理文件夹
            var dirs = Directory.GetDirectories(workPath);

            for (int i = 0; i < dirs.Length; ++i)
            {
                string fileName = Path.GetFileName(dirs[i]);

                fileName = string.Format("{0}/{1}", folderPath, fileName);
                CollectABInFolder(fileName, builderData);
            }
        }
Beispiel #2
0
        private static void RemoveInvalidAssetBundleInner(string absPath, AssetDataTable table)
        {
            string[] dirs = Directory.GetDirectories(absPath);

            if (dirs != null && dirs.Length > 0)
            {
                for (int i = 0; i < dirs.Length; ++i)
                {
                    RemoveInvalidAssetBundleInner(dirs[i], table);
                }
            }

            string[] files = Directory.GetFiles(absPath);
            if (files != null && files.Length > 0)
            {
                for (int i = 0; i < files.Length; ++i)
                {
                    string p = PathHelper.AssetBundlePath2ABName(files[i]);
                    if (!AssetFileFilter.IsAssetBundle(p))
                    {
                        continue;
                    }
                    //Log.I("清除name:" + p);
                    if (table.GetABUnit(p) == null)
                    {
                        File.Delete(files[i]);
                        File.Delete(files[i] + ".meta");
                        File.Delete(files[i] + ".manifest");
                        File.Delete(files[i] + ".manifest.meta");

                        Log.I("Delete Invalid AB:" + p);
                    }
                }

                files = Directory.GetFiles(absPath);
                if (files == null || files.Length == 0)
                {
                    Directory.Delete(absPath);
                }
            }
            else
            {
                Directory.Delete(absPath);
            }
        }