Esempio n. 1
0
        public virtual void Save(Stream stream, AssetTarget[] targets)
        {
            StreamWriter sw = new StreamWriter(stream);

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

            for (int i = 0; i < targets.Length; i++)
            {
                AssetTarget           target = targets[i];
                HashSet <AssetTarget> deps   = new HashSet <AssetTarget>();
                target.GetDependencies(deps);

                //debug name
                sw.WriteLine(target.assetPath);
                //bundle name
                sw.WriteLine(target.bundleName);
                //File Name
                sw.WriteLine(target.bundleShortName);
                //hash
                sw.WriteLine(target.bundleCrc);
                //type
                sw.WriteLine((int)target.compositeType);
                //写入依赖信息
                sw.WriteLine(deps.Count);

                foreach (AssetTarget item in deps)
                {
                    sw.WriteLine(item.bundleName);
                }
                sw.WriteLine("<------------->");
            }
            sw.Close();
        }
        public override void Save(Stream stream, AssetTarget[] targets)
        {
            BinaryWriter sw = new BinaryWriter(stream);

            //写入文件头判断文件类型用,ABDB 意思即 Asset-Bundle-Data-Binary
            sw.Write(new char[] { 'A', 'B', 'D', 'B' });

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

            for (int i = 0; i < targets.Length; i++)
            {
                AssetTarget target = targets[i];
                bundleNames.Add(target.bundleName);
            }

            //写入文件名池
            sw.Write(bundleNames.Count);
            for (int i = 0; i < bundleNames.Count; i++)
            {
                sw.Write(bundleNames[i]);
            }

            //写入详细信息
            for (int i = 0; i < targets.Length; i++)
            {
                AssetTarget           target = targets[i];
                HashSet <AssetTarget> deps   = new HashSet <AssetTarget>();
                target.GetDependencies(deps);

                //debug name
                sw.Write(target.assetPath);
                //bundle name
                sw.Write(bundleNames.IndexOf(target.bundleName));
                //File Name
                sw.Write(target.bundleShortName);
                //hash
                sw.Write(target.bundleCrc);
                //type
                sw.Write((int)target.compositeType);
                //写入依赖信息
                sw.Write(deps.Count);

                foreach (AssetTarget item in deps)
                {
                    sw.Write(bundleNames.IndexOf(item.bundleName));
                }
            }
            sw.Close();
        }