Esempio n. 1
0
        /// <summary>
        /// 获取Loader
        /// </summary>
        /// <param name="hash"></param>
        /// <returns></returns>
        public static ABLoader GetLoader(uint hash, ABLoadContext _loadContext)
        {
            //如果已经存在Laoder则返回loader
            if (_loadContext.loadingLoaderDict.ContainsKey(hash))
            {
                return(_loadContext.loadingLoaderDict[hash]);
            }

            ABData data = _loadContext.dataHelper.GetABData(hash);

            if (data == null)
            {
                ReDebug.LogError(ReLogType.System, "ABManager",
                                 string.Format("ABData is null, abName={0}", hash));
                return(null);
            }

            //创建Loader并且加入表中
            ABLoader loader = ReusableObjectPool <ABLoader> .Get();

            loader.abName = data.fullName;
            loader.abData = data;
            _loadContext.loadingLoaderDict[hash] = loader;
            loader._loadContext = _loadContext;

            return(loader);
        }
Esempio n. 2
0
        private void writeText(Stream fs)
        {
            StreamWriter sw = new StreamWriter(fs);

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

            foreach (KeyValuePair <uint, ABData> pair in _infoMap)
            {
                ABData data = pair.Value;
                if (data == null)
                {
                    continue;
                }
                sw.WriteLine(data.debugName);          // debug name
                sw.WriteLine(data.fullName + ".ab");   // bundle name
                sw.WriteLine(data.hash);               // file hash
                sw.WriteLine((int)data.compositeType); // export type

                if (data.dependencies == null)
                {
                    UnityEngine.Debug.LogError("##### " + data.debugName);
                }
                sw.WriteLine(data.dependencies.Length);
                foreach (uint name in data.dependencies)
                {
                    sw.WriteLine(name + ".ab");
                }
                sw.WriteLine("<------------->");
            }
            sw.Close();
        }
Esempio n. 3
0
        private void readBin(Stream fs)
        {
            if (fs.Length < 4)
            {
                return;
            }

            BinaryReader sr = new BinaryReader(fs);

            char[] fileHeadChars = sr.ReadChars(4);
            //读取文件头判断文件类型,ABDB 意思即 Asset-Bundle-Data-Binary
            if (fileHeadChars[0] != 'A' || fileHeadChars[1] != 'B' || fileHeadChars[2] != 'D' || fileHeadChars[3] != 'B')
            {
                return;
            }

            int namesCount = sr.ReadInt32();

            uint[] names = new uint[namesCount];
            for (int i = 0; i < namesCount; i++)
            {
                names[i] = uint.Parse(sr.ReadString().Replace(".ab", ""));
            }

            while (true)
            {
                if (fs.Position == fs.Length)
                {
                    break;
                }
                string debugName = sr.ReadString();
                uint   name      = names[sr.ReadInt32()];
                string hash      = sr.ReadString();
                int    typeData  = sr.ReadInt32();
                int    depsCount = sr.ReadInt32();

                uint[] deps = new uint[depsCount];
                for (int i = 0; i < depsCount; i++)
                {
                    deps[i] = names[sr.ReadInt32()];
                }

                ABData info = new ABData();
                info.hash          = hash;
                info.fullName      = name;
                info.debugName     = debugName;
                info.dependencies  = deps;
                info.compositeType = (ABExportType)typeData;
                _infoMap[name]     = info;
            }
            sr.Close();
        }
Esempio n. 4
0
        private void writeBin(Stream fs)
        {
            BinaryWriter sw = new BinaryWriter(fs);

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

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

            abDataList.AddRange(_infoMap.Values);
            for (int i = 0; i < abDataList.Count; i++)
            {
                bundleNames.Add(abDataList[i].fullName + ".ab");
            }

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

            //写入详细信息
            for (int i = 0; i < abDataList.Count; i++)
            {
                ABData data = abDataList[i];

                sw.Write(data.debugName);                             //debug name
                sw.Write(bundleNames.IndexOf(data.fullName + ".ab")); //bundle name
                sw.Write(data.hash);                                  //file hash
                sw.Write((int)data.compositeType);                    //export type

                sw.Write(data.dependencies.Length);
                foreach (uint name in data.dependencies)
                {
                    sw.Write(bundleNames.IndexOf(name + ".ab"));
                }
            }
            sw.Close();
        }
Esempio n. 5
0
        private void readText(Stream fs)
        {
            StreamReader sr = new StreamReader(fs);

            char[] fileHeadChars = new char[6];
            sr.Read(fileHeadChars, 0, fileHeadChars.Length);
            //读取文件头判断文件类型,ABDT 意思即 Asset-Bundle-Data-Text
            if (fileHeadChars[0] != 'A' || fileHeadChars[1] != 'B' || fileHeadChars[2] != 'D' || fileHeadChars[3] != 'T')
            {
                return;
            }

            while (true)
            {
                string debugName = sr.ReadLine();
                if (string.IsNullOrEmpty(debugName))
                {
                    break;
                }
                uint   name      = uint.Parse(sr.ReadLine().Replace(".ab", ""));
                string hash      = sr.ReadLine();
                int    typeData  = Convert.ToInt32(sr.ReadLine());
                int    depsCount = Convert.ToInt32(sr.ReadLine());

                uint[] deps = new uint[depsCount];
                for (int i = 0; i < depsCount; i++)
                {
                    deps[i] = uint.Parse(sr.ReadLine().Replace(".ab", ""));
                }
                sr.ReadLine(); // skip <------------->

                ABData info = new ABData();
                info.debugName     = debugName;
                info.hash          = hash;
                info.fullName      = name;
                info.dependencies  = deps;
                info.compositeType = (ABExportType)typeData;
                _infoMap[name]     = info;
            }
            sr.Close();
        }
Esempio n. 6
0
 public ABObject(uint abName, ABData data, AssetBundle bundle)
 {
     this.abName  = abName;
     this.abData  = data;
     this._bundle = bundle;
 }