Ejemplo n.º 1
0
 /// <summary>
 /// 检查依赖资源是否已经加载完成,如果没有,则重新加载
 /// </summary>
 public virtual void CheckDependences()
 {
     this.dependences = ResMgr.Instance().GetDependences(base.ResName);
     for (int i = 0; i < this.dependences.Length; ++i)
     {
         string dependence = this.dependences[i];
         if (!ResMgr.Instance().IsLoadedAssetBundle(dependence))
         {
             ResMgr.Instance().LoadRes(dependence);
         }
     }
 }
Ejemplo n.º 2
0
 public override bool IsDone()
 {
     // 如果有依赖,要先判断依赖是否已经加载完成
     if (this.dependences != null)
     {
         for (int i = 0; i < this.dependences.Length; ++i)
         {
             if (!ResMgr.Instance().IsLoadedAssetBundle(this.dependences[i]))
             {
                 return(false);
             }
         }
     }
     // 判断自己是否加载完成
     if (base.LoadDoneCallback == null)
     {
         // 依赖资源,不需要LoadDone回调
         if (this.assetbundle != null)
         {
             return(true);
         }
         if (this.www.isDone)
         {
             this.assetbundle = this.www.assetBundle;
             this.www.Dispose();
             this.www = null;
             return(true);
         }
         return(false);
     }
     else
     {
         // 直接资源,需要LoadDone回调,所以需要从AssetBundle中提取资源对象
         if (this.assetbundleReq != null)
         {
             // 只有从assetbundle中提取出最终的资源对象,才算加载完成,保证所有的IO操作都是异步的
             return(this.assetbundleReq.isDone);
         }
         else
         {
             if (this.www.isDone)
             {
                 this.assetbundle = this.www.assetBundle;
                 // 从assetbundle中提取资源对象
                 string resPath = string.Format(LocalPath.AssetBundleFormation, base.ResName);
                 this.assetbundleReq = this.assetbundle.LoadAssetAsync(resPath);
                 this.www.Dispose();
                 this.www = null;
             }
             return(false);
         }
     }
 }
Ejemplo n.º 3
0
        public void PreloadMusic(string path, int id)
        {
            QTest.TimeBegan(path);

            ResMgr.Instance().LoadRes(path, delegate(string resName, Object resObj) {
                if (resObj)
                {
                    if (APP_CONFIG.DEBUG)
                    {
                        QPrint.Warn("loaded: " + path + " " + id.ToString() + "time:" + QTest.TimeStop(path));
                    }
                    musicClips[id] = resObj as AudioClip;
                }
            });
        }
Ejemplo n.º 4
0
 public override bool IsDone()
 {
     if (this.dependences != null)
     {
         for (int i = 0; i < this.dependences.Length; ++i)
         {
             if (!ResMgr.Instance().IsLoadedAssetBundle(this.dependences[i]))
             {
                 return(false);
             }
         }
     }
     if (this.op != null)
     {
         return(this.op.isDone);
     }
     else
     {
         if (this.www.isDone)
         {
             this.assetbundle = this.www.assetBundle;
             string scene = base.SceneName.Substring(0, base.SceneName.LastIndexOf('.'));
             if (this.additive)
             {
                 this.op = Application.LoadLevelAdditiveAsync(scene);
             }
             else
             {
                 this.op = Application.LoadLevelAsync(scene);
             }
             this.www.Dispose();
             this.www = null;
         }
         return(false);
     }
 }