Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
        bool DoLoadSync(AssetLoadRequest req)
        {
            var handle = GetLoadHandle(req.path);

            req.assetHandle = handle.Load(req.type);
            req.Complete();
            return(req.assetHandle.isValid);
        }
Ejemplo n.º 3
0
 private void OnLoadCompleted(Object asset, AssetLoadRequest req)
 {
     loaded[req.path] = new WebAssetInfo()
     {
         asset       = asset,
         unusedFrame = 0,
     };
     req.assetHandle = new AssetHandle(asset, refMgr.GetOrCreateRef(asset));
     req.Complete();
 }
Ejemplo n.º 4
0
 public bool LoadAsync(AssetLoadRequest req)
 {
     req.Complete();
     return(false);
 }
Ejemplo n.º 5
0
 public bool LoadAsync(AssetLoadRequest req)
 {
     req.assetHandle = Load(req.type);
     req.Complete();
     return(req.assetHandle.isValid);
 }