示例#1
0
        public void Init(Stream depStream, Action callback)
        {
            if (depStream.Length > 4)
            {
                BinaryReader br = new BinaryReader(depStream);
                if (br.ReadChar() == 'A' && br.ReadChar() == 'B' && br.ReadChar() == 'D')
                {
                    if (br.ReadChar() == 'T')
                    {
                        _depInfoReader = new AssetBundleDataReader();
                    }
                    else
                    {
                        _depInfoReader = new AssetBundleDataBinaryReader();
                    }

                    depStream.Position = 0;
                    _depInfoReader.Read(depStream);
                }
            }

            depStream.Close();

            if (callback != null)
            {
                callback();
            }
        }
示例#2
0
    public void Init(byte[] bytes)
    {
        MemoryStream depStream = new MemoryStream(bytes);

        if (depStream.Length > 4)
        {
            BinaryReader br = new BinaryReader(depStream);
            if (br.ReadChar() == 'A' && br.ReadChar() == 'B' && br.ReadChar() == 'D')
            {
                if (br.ReadChar() == 'T')
                {
                    depInfoReader = new AssetBundleDataReader();
                }
                else
                {
                    depInfoReader = new AssetBundleDataBinaryReader();
                }
                depStream.Position = 0;
                depInfoReader.Read(depStream);
            }
            else
            {
                XDebug.LogError("not find dep");
            }
        }
        depStream.Close();
    }
        /// <summary>
        /// 解析dep文件  参数1:dep文件路径   返回所有资源名字
        /// </summary>
        public static List <string> ResolveDepFile(string depFilePath)
        {
            var tempReader = new AssetBundleDataReader();

            using (FileStream fs = new FileStream(depFilePath, FileMode.Open, FileAccess.Read))
            {
                tempReader.Read(fs);
                DebugManager.Log(depFilePath + "  dep文件读取成功!读取到的ab资源个数为:" + tempReader.infoMap.Count);
                List <string> resolveDepName = new List <string>();
                foreach (var v in tempReader.infoMap)
                {
                    if (!resolveDepName.Contains(v.Value.fullName))
                    {
                        resolveDepName.Add(v.Value.fullName);
                    }
                }
                tempReader = null;
                return(resolveDepName);
            }
        }
 /// <summary>
 /// 初始化当前最新的dep.all ab列表
 /// </summary>
 private void InitDepList(string depFilePath)
 {
     curentDepFileReader = new AssetBundleDataReader();
     using (FileStream fs = new FileStream(depFilePath, FileMode.Open, FileAccess.Read))
     {
         curentDepFileReader.Read(fs);
         DebugManager.Log(depFilePath + "  dep文件读取成功!读取到的ab资源个数为:" + curentDepFileReader.infoMap.Count);
         curentDepFileABDataDic = new Dictionary <string, AssetBundleData>();
         foreach (var v in curentDepFileReader.infoMap)
         {
             if (!curentDepFileABDataDic.ContainsKey(v.Value.debugName))
             {
                 curentDepFileABDataDic.Add(v.Value.debugName, v.Value);
             }
             else
             {
                 DebugManager.LogWarning("dep文件读取到的" + v.Value.debugName + "资源重复!");
             }
         }
     }
 }
 protected override void OnDestroy()
 {
     curentDepFileReader    = null;
     curentDepFileABDataDic = null;
     base.OnDestroy();
 }