Пример #1
0
 bool AddStreamAtPath(ref AssetBundleContext context, string assetpath)
 {
     if (File.Exists(assetpath))
     {
         IParseDependencyReader reader = AssetBundleTypeGetter.GetDepReader();
         if (reader != null)
         {
             if (reader.IsAsync)
             {
                 Block = true;
                 GUpdater.mIns.StartCoroutine(TryRead(reader, assetpath));
             }
             else
             {
                 List <AssetBundleInfo> list;
                 if (reader.Read(assetpath, out list))
                 {
                     context.Cache.Load(list);
                     ListPool <AssetBundleInfo> .Release(list);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }
        public IEnumerator Init(string url)
        {
            using (var request = UnityWebRequest.Get(url + "/" + AssetBundleConfig.DepFileName))
            {
                yield return(request.Send());

                if (request.responseCode != 200)
                {
                    Debug.LogErrorFormat("Http Error :{0} Info: {1}", request.url, request.downloadHandler.text);
                }
                else if (!string.IsNullOrEmpty(request.error))
                {
                    Debug.LogErrorFormat("Error :{0} Info: {1}", request.error, request.downloadHandler.text);
                }
                else
                {
                    string perpath = AssetBundleHelper.GetBundlePersistentPath(AssetBundleConfig.DepFileName);
                    string dirname = Path.GetDirectoryName(perpath);
                    if (!Directory.Exists(dirname))
                    {
                        Directory.CreateDirectory(dirname);
                    }

                    File.WriteAllBytes(perpath, request.downloadHandler.data);

                    var getter = AssetBundleTypeGetter.GetDepReader();

                    List <AssetBundleInfo> list = new List <AssetBundleInfo>();
                    getter.ReadBytes(list, request.downloadHandler.data);

                    if (_dict == null)
                    {
                        _dict = new Dictionary <IgnoreCaseString, string>();
                    }

                    foreach (var element in list)
                    {
                        IgnoreCaseString key = new IgnoreCaseString(element.AssetBundleName);
                        _dict[key] = url + "/" + element.AssetBundleName;
                    }
                }

                IsDone = true;
            }
        }
Пример #3
0
 bool AddPersistentAtPath(ref AssetBundleContext context, string assetpath)
 {
     if (File.Exists(assetpath))
     {
         IParseDependencyReader reader = AssetBundleTypeGetter.GetDepReader();
         if (reader != null)
         {
             List <AssetBundleInfo> list;
             if (reader.Read(assetpath, out list))
             {
                 context.Cache.Load(list);
                 ListPool <AssetBundleInfo> .Release(list);
             }
             return(true);
         }
     }
     return(false);
 }