Esempio n. 1
0
        protected override void Save(System.IO.Stream stream, AssetBundleTarget[] targets)
        {
            StreamWriter sw = new StreamWriter(stream);

            //写入头文件判断文件类型用,ABDT 即 Asset Bundle Data Text
            sw.WriteLine("ABDT");
            sw.WriteLine(AssetBundleManager.version.ToString());

            for (int ii = 0; ii < targets.Length; ++ii)
            {
                AssetBundleTarget target = targets[ii];

                sw.WriteLine(target.bundleName);
                sw.WriteLine(target.bundleShortName);
                sw.WriteLine(target.bundleCRC);
                sw.WriteLine(target.size);
                sw.WriteLine(target.parents.Count);
                foreach (AssetBundleTarget parent in target.parents)
                {
                    sw.WriteLine(parent.bundleName);
                }
            }

            sw.Close();
        }
        private void AddTargets(AssetBundleConfigNode configNode)
        {
            if (!configNode.enabled)
            {
                return;
            }

            int idx = _config.allDependNodes.IndexOf(configNode);
            AssetBundleConfigNode nextConfigNode = idx >= 0 && idx < _config.allDependNodes.Count - 1 ? _config.allDependNodes[idx + 1] : null;
            bool            hasChild             = nextConfigNode != null && nextConfigNode.level > configNode.level;
            AssetBundleNode node = new AssetBundleNode(configNode.ID, configNode.level, configNode.isIndependent, hasChild);

            List <string> assetPaths = new List <string>();

            foreach (AssetBundleFilter filter in configNode.filters)
            {
                if (!filter.valid)
                {
                    continue;
                }

                string filterPath = AssetBundleUtils.ConvertToAbsolutePath(configNode.dir) + "/" + filter.path;
                if (Directory.Exists(filterPath))
                {
                    string[] filterList = filter.filter.Split(';');
                    foreach (string fil in filterList)
                    {
                        string[] paths = Directory.GetFiles(filterPath, fil, filter.searchOption);
                        foreach (string path in paths)
                        {
                            if (path.Contains("\\Editor\\") || path.EndsWith(".meta"))
                            {
                                continue;
                            }

                            assetPaths.Add(AssetBundleUtils.ConvertToAssetPath(path));
                        }
                    }
                }
                else
                {
                    assetPaths.Add(configNode.dir + "/" + filter.path);
                }
            }

            if (configNode.exportType == ExportType.Whole)
            {
                AssetBundleTarget at = new AssetBundleTarget(configNode.name, configNode.dir, node, null, ref assetPaths);
                node.targets.Add(at);
            }
            else
            {
                foreach (var path in assetPaths)
                {
                    AssetBundleTarget at = new AssetBundleTarget(configNode.name, configNode.dir, node, path, ref assetPaths);
                    node.targets.Add(at);
                }
            }

            _dependNodes.Add(node);
        }