static IEnumerable <string> CreateTableByTableCondition(
            AssetBundleEncryptor encryptor,
            string tableDirPath,
            AssetBundleManifest manifest,
            BuildTarget buildTarget,
            AssetBundleTableCondition tableCondition,
            Dictionary <string, List <AssetEntryRecordCandidate> > assetEntryRecordCandidateLists)
        {
            foreach (AssetEntryRecordCandidate candidate in assetEntryRecordCandidateLists.Values.SelectMany(c => c))
            {
                candidate.PrepareTagSets(tableCondition);
            }

            foreach (AssetEntryRecordFilter filter in tableCondition.EnumerateFilters())
            {
                string tableFilePath = $"{tableDirPath}{filter.TableFilePath}.asset";
                IEnumerable <AssetEntryRecord> assetEntryRecords = assetEntryRecordCandidateLists
                                                                   .Where(pair => tableCondition.GetNecessityFunc.Invoke(pair.Key))
                                                                   .Select(pair => pair.Value)
                                                                   .Select(candidates => filter.Filterate(candidates))
                                                                   .Where(record => record != null);

                CreateTableByAssetEntryRecords(
                    encryptor,
                    manifest,
                    tableFilePath,
                    buildTarget,
                    assetEntryRecords);

                yield return(tableFilePath);
            }
        }
Exemplo n.º 2
0
        public void PrepareTagSets(AssetBundleTableCondition tableCondition)
        {
            this.TagsDictionary.Clear();

            foreach (TagConditionSet tabConditionSet in tableCondition.TagConditionSets)
            {
                IEnumerable <string> containedTags = tabConditionSet.UsingTags.Where(t => tags.Contains(t));

                this.TagsDictionary.Add(
                    tabConditionSet.Id,
                    new FixedHashSet <string>(containedTags));
            }
        }
        // return vale = table file paths
        public static List <string> CreateTables(
            AssetBundleEncryptor encryptor,
            string tableDirPath,
            string manifestPath,
            BuildTarget buildTarget,
            AssetBundleTableCondition tableCondition)
        {
            List <string> tableFilePaths = new List <string>();

            AssetBundle assetBundle = AssetBundle.LoadFromFile(manifestPath);

            try
            {
                AssetBundleManifest manifest = (AssetBundleManifest)assetBundle.LoadAsset("AssetBundleManifest", typeof(AssetBundleManifest));

                string planeAssetBundleDirPath        = encryptor.PlaneAssetBundleDirPath;
                var    assetEntryRecordCandidateLists = manifest.GetAllAssetBundles()
                                                        .SelectMany(assetBundleName => EnumerateAssetEntryRecords(planeAssetBundleDirPath, assetBundleName))
                                                        .GroupBy(r => r.AssetEntryRecord.AssetEntryKey)
                                                        .ToDictionary(g => g.Key, g => g.ToList());

                IEnumerable <string> createdTableFilePaths = CreateTableByTableCondition(
                    encryptor,
                    tableDirPath,
                    manifest,
                    buildTarget,
                    tableCondition,
                    assetEntryRecordCandidateLists);

                tableFilePaths.AddRange(createdTableFilePaths);

                AssetDatabase.SaveAssets();
            }
            finally
            {
                assetBundle.Unload(true);
            }

            return(tableFilePaths);
        }
Exemplo n.º 4
0
        public static void CreateAndBuildAssetBundleTable(AssetBundleEncryptor encryptor, string assetBundleTableDirPath, BuildTarget buildTarget, AssetBundleTableCondition tableCondition)
        {
            string tableDirPath = GetAssetBundleDir(assetBundleTableDirPath, buildTarget);

            string assetBundleDirName = encryptor.PlaneAssetBundleDirPath;
            string manifestPath       = BackUpManifest(assetBundleDirName, buildTarget);

            List <string> tableFilePaths = AssetBundleTableCreator.CreateTables(
                encryptor,
                tableDirPath,
                manifestPath,
                buildTarget,
                tableCondition);

            AssetBundleEditor.BuildAssetBundleTable(encryptor, tableDirPath, tableFilePaths, buildTarget);

            Debug.Log($"Finish building asset bundle table");
        }