예제 #1
0
        private static DependenciesInfo ParseBundleDependenciesFromRules(BundlerBuildRule buildRule,
                                                                         ref ReservedSharedBundleInfo reserved, ref DependencyCache cache)
        {
            buildRule.rules.Sort((a, b) => - a.shared.CompareTo(b.shared));

            var depsInfo = new DependenciesInfo();

            foreach (var rule in buildRule.rules)
            {
                var packType = (PackType)Enum.Parse(typeof(PackType), rule.packType);
                switch (packType)
                {
                case PackType.PackByFile:
                    ParseBundleDependenciesByRuleOfPackByFile(rule, ref depsInfo, ref reserved, ref cache);
                    break;

                case PackType.PackByDirectory:
                    ParseBundleDependenciesByRuleOfPackByDirectory(rule, ref depsInfo, ref reserved, ref cache);
                    break;

                case PackType.PackBySubDirectory:
                    ParseBundleDependenciesByRuleOfPackBySubDirectory(rule, ref depsInfo, ref reserved, ref cache);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(rule.packType);
                }
            }

            return(depsInfo);
        }
예제 #2
0
        private static string[] GetManagedFilesByRules(BundlerBuildRule rules)
        {
            var files = new HashSet <string>();

            rules.managed.ForEach(v => {
                var ret = GetFileListByRule(v);
                foreach (var file in ret)
                {
                    files.Add(file);
                }
            });
            return(files.ToArray());
        }
예제 #3
0
        public static BundlerManifest GenerateManifest(BundlerBuildRule buildRule)
        {
            var cache = LoadAssetDependenciesCache();
            var reservedSharedBundle = new ReservedSharedBundleInfo();
            var depsInfo             = ParseBundleDependenciesFromRules(buildRule, ref reservedSharedBundle, ref cache);
            var bundlesInfo          = GenerateBundlesInfo(ref depsInfo, ref reservedSharedBundle, ref cache);

            ResolveBundleDependencies(ref bundlesInfo, ref cache);
            //FilterRedundantDependencies(ref bundlesInfo);
            var manifest = GenerateBundlerManifest(ref bundlesInfo);

            Resources.UnloadUnusedAssets();
            SaveAssetDependenciesCache(cache);
            return(manifest);
        }
예제 #4
0
        public static void StripUnmanagedFiles(BundlerBuildRule buildRule, BundlerManifest manifest)
        {
            var managedFiles = GetManagedFilesByRules(buildRule);
            var toRemoved    = new List <string>();

            foreach (var kv in manifest.assets)
            {
                if (!managedFiles.Contains(kv.Key))
                {
                    toRemoved.Add(kv.Key);
                }
            }
            toRemoved.ForEach(v => manifest.assets.Remove(v));
            Debug.Log(string.Format("{0} unmanaged files removed from manifest.", toRemoved.Count));
        }
예제 #5
0
        public static void GenerateManifestToFile(BundlerBuildRule buildRule, string outputPath)
        {
            var manifest = GenerateManifest(buildRule);

            SaveManifest(ref manifest, outputPath);
        }