コード例 #1
0
        public void LoadFromMemory(Stream depStream)
        {
            caches.Clear();
            StreamReader sr = new StreamReader(depStream);

            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 name = sr.ReadLine();
                if (string.IsNullOrEmpty(name))
                {
                    break;
                }

                string shortFileName = sr.ReadLine();
                string hash          = sr.ReadLine();
                string assetpath     = sr.ReadLine();
                Convert.ToInt32(sr.ReadLine());
                int      depsCount = Convert.ToInt32(sr.ReadLine());
                string[] deps      = new string[depsCount];

                if (FrameWorkConfig.Open_DEBUG)
                {
                    LogMgr.Log("asset :" + assetpath);
                }

                for (int i = 0; i < depsCount; i++)
                {
                    deps[i] = sr.ReadLine();
                }

                BundlePkgInfo pkg = new BundlePkgInfo(hash, name, shortFileName, assetpath, BundlePkgInfo.ChooseType(assetpath), deps);
                this.caches[shortFileName] = pkg;
                this.caches[name]          = pkg;
                this.caches[assetpath]     = pkg;

                if (BundleConfig.SAFE_MODE)
                {
#if UNITY_EDITOR
                    this.caches.Add(assetpath.Replace("\\", "/"), pkg);
#else
                    this.caches.Add(assetpath, pkg);
#endif
                }
            }

            if (FrameWorkConfig.Open_DEBUG)
            {
                LogMgr.LogFormat("Bundle Count Is {0}", this.caches.Count);
            }

            depStream.Close();
        }
コード例 #2
0
        private void ReadBinary(BinaryReader sr, Stream fs)
        {
            int namesCount = sr.ReadInt32();

            string[] names = new string[namesCount];
            for (int i = 0; i < namesCount; i++)
            {
                names[i] = sr.ReadString();
            }

            while (true)
            {
                if (fs.Position == fs.Length)
                {
                    break;
                }

                string name          = names[sr.ReadInt32()];
                string shortFileName = sr.ReadString();
                string hash          = sr.ReadString();
                string assetpath     = sr.ReadString();
                sr.ReadInt32();//int typeData =
                int      depsCount = sr.ReadInt32();
                string[] deps      = new string[depsCount];
                //LogMgr.LogError(shortFileName +" > "+assetpath);

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


                BundlePkgInfo pkg = new BundlePkgInfo(hash, name, shortFileName, assetpath, BundlePkgInfo.ChooseType(assetpath), deps);

#if UNITY_EDITOR
                TryAdd(assetpath, pkg);
                TryAdd(shortFileName, pkg);
                TryAdd(name, pkg);
#else
                this.caches[shortFileName] = pkg;
                this.caches[name]          = pkg;//hashvalue
#endif

                if (BundleConfig.SAFE_MODE)
                {
#if UNITY_EDITOR
                    this.caches[assetpath.Replace("\\", "/")] = pkg;
#endif
                }
            }

            if (FrameWorkConfig.Open_DEBUG)
            {
                LogMgr.LogFormat("Bundle Count Is {0}", this.caches.Count);
            }

            sr.Close();
        }