Beispiel #1
0
        public void Load(AssetLoadRequest req)
        {
            string url = req.url;

            if (loaded.TryGetValue(url, out var info))
            {
                //已经加载完了
                info.unusedFrame = 0;
                req.assetHandle  = new AssetHandle(info.asset, refMgr.GetOrCreateRef(info.asset));
                req.Complete();
                return;
            }

            var webReq = req.GetData <UnityWebRequest>("__webRequest");

            if (webReq == null)
            {
                webReq = UnityWebRequest.Get(url);
            }
            var opt = webReq.SendWebRequest();

            opt.completed += OnRequestCompelted;

            if (loadingReqs.TryGetValue(url, out var reqs))
            {
                reqs.Add(req);
            }
            else
            {
                reqs = new List <AssetLoadRequest>();
                reqs.Add(req);
                loadingReqs[url] = reqs;
            }
        }
Beispiel #2
0
 bool DoLoadAsync(AssetLoadRequest req)
 {
     if (!req.isUrl)
     {
         var handle = GetLoadHandle(req.path);
         return(handle.LoadAsync(req));
     }
     else
     {
         var group = req.GetData <string>("__webGroup");
         if (webLoaders.TryGetValue(group, out var loader))
         {
             loader.Load(req);
             return(true);
         }
         return(false);
     }
 }