Esempio n. 1
0
        void CheckChildren(bool checkChannel)
        {
            if (importer == null)
            {
                return;
            }

            var childrenImporters = importer.GetChildren();
            var checkerConfig     = new AssetBundleCheckerConfig();

            foreach (var childrenImport in childrenImporters)
            {
                if (config.Type == AssetBundleDispatcherFilterType.ChildrenFilesOnly && !childrenImport.IsFile)
                {
                    continue;
                }
                else if (config.Type == AssetBundleDispatcherFilterType.ChildrenFoldersOnly && childrenImport.IsFile)
                {
                    continue;
                }

                checkerConfig.CheckerFilters = config.CheckerFilters;
                checkerConfig.PackagePath    = childrenImport.packagePath;
                AssetBundleChecker.Run(checkerConfig, checkChannel);
            }
        }
        public static List <string> RemoveAssetBundleInChildren(string assetPath, bool containsSelf, bool countainsDirectly, REMOVE_TYPE removeType)
        {
            List <string>       removeList = new List <string>();
            AssetBundleImporter importer   = AssetBundleImporter.GetAtPath(assetPath);

            if (importer == null)
            {
                return(removeList);
            }

            //是否删除自身
            if (containsSelf && !string.IsNullOrEmpty(importer.assetBundleName))
            {
                removeList.Add(string.Format("{0}{1}", importer.assetPath,
                                             string.IsNullOrEmpty(importer.assetBundleVariant) ? null : string.Format("({0})", importer.assetBundleVariant)));
                importer.assetBundleName = null;
            }

            List <AssetBundleImporter> childImporter = importer.GetChildren();

            foreach (AssetBundleImporter child in childImporter)
            {
                if (!child.IsValid)
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(child.assetBundleName) && countainsDirectly)
                {
                    if (removeType == REMOVE_TYPE.ALL ||
                        (removeType == REMOVE_TYPE.CHILDREN_DIR && child.IsFile == false) ||
                        (removeType == REMOVE_TYPE.CHILDREN_FILES && child.IsFile == true)
                        )
                    {
                        removeList.Add(string.Format("{0}{1}", child.assetPath,
                                                     string.IsNullOrEmpty(child.assetBundleVariant) ? null : string.Format("({0})", child.assetBundleVariant)));
                        child.assetBundleName = null;
                    }
                }
                if (!child.IsFile)
                {
                    // 为目录,递归:递归时containsSelf设置为false,是否删除本身由removeType确定
                    removeList.AddRange(RemoveAssetBundleInChildren(child.assetPath, false, true, removeType));
                }
            }
            return(removeList);
        }
        public static void CreateAssetbundleForChildren(AssetBundleImporter importer)
        {
            if (importer == null || !importer.IsValid)
            {
                Debug.LogError("importer null or not valid!");
                return;
            }

            List <AssetBundleImporter> childImporter = importer.GetChildren();

            foreach (AssetBundleImporter child in childImporter)
            {
                if (!child.IsValid)
                {
                    continue;
                }

                CreateAssetbundleForCurrent(child);
            }
        }