Beispiel #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);
 }
Beispiel #2
0
        void DownLoadAssetBundle(ref AssetBundleContext context, ref AssetDownloadInfo downloadtask)
        {
            if (!downloadtask.IsDone && !downloadtask.IsDownloading)
            {
                downloadtask.Loader = AssetBundleTypeGetter.GetDownloader();
            }

            //update
            downloadtask.Loader.DownLoad(ref downloadtask);


            if (downloadtask.TaskId >= 0)
            {
                for (int i = 0; i < context.Tasks.Count; i++)
                {
                    var assettask = context.Tasks[i];
                    if (assettask.TaskId == downloadtask.TaskId)
                    {
                        if (assettask.Result.ProgresCallback != null)
                        {
                            int finishcnt;
                            int totalcnt;
                            assettask.IsSubAllDone(ref context, out finishcnt, out totalcnt);

                            ProgressArgs progressArgs = new ProgressArgs((float)finishcnt / totalcnt, 0, assettask.AssetPath, true);
                            assettask.Result.ProgresCallback(ref progressArgs);
                        }
                        break;
                    }
                }
            }
        }
        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;
            }
        }
Beispiel #4
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);
 }
Beispiel #5
0
        public int Init(ref AssetBundleContext context)
        {
            if (_remote == null)
            {
                string url = AssetBundleConfig.DownloadUrl;
                _remote = AssetBundleTypeGetter.GetRemoteAssets();
                GUpdater.mIns.StartCoroutine(ParseRemote(url));
            }

            Block = !_remote.IsDone;

            if (_remote.IsDone)
            {
                context.Cache.InitRemote(_remote);
                _remote = null;
            }
            return(0);
        }