Example #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();
        }
Example #2
0
        public void LoadFromMemory(Stream depStream)
        {
            caches.Clear();
            if (depStream.Length > 4)
            {
                BinaryReader br = new BinaryReader(depStream);
                if (br.ReadChar() == 'A' && br.ReadChar() == 'B' && br.ReadChar() == 'D')
                {
                    char c = br.ReadChar();
                    if (c != 'B')
                    {
                        throw new FrameWorkException(string.Format("核心资源异常"), ExceptionType.HighDanger_Exception);
                    }
                    this.ReadBinary(br, depStream);
                }
            }

            depStream.Close();
        }
Example #3
0
 public void Clear()
 {
     objpool.RemoveChildren();
     pool.Clear();
 }