示例#1
0
 public LoadHelper(string url, OnResLoadOK cbFunc = null)
 {
     this.url = url;
     if (cbFunc != null)
     {
         onLoadOK = new OnResLoadOK(cbFunc);
     }
 }
示例#2
0
    public bool GetDllRes(string dllName, OnResLoadOK callback)
    {
        //        string ResURL = Config.GetHeroResourcePath(cardId);
        //        LoadHelper helper = new LoadHelper(ResURL);
        //        helper.resType = LoadHelper.RESTYPE.RESOUCE;
        //        helper.loadError = false;
        //        var gameObj = Resources.Load(ResURL);
        //        if (gameObj == null)
        //        {
        //            Log.Cly("Resources没有" + ResURL + "资源");
        //            return GetRes(Config.GetHeroPath(cardId), callback, LoadPriority.Normal);
        //        }
        //        else
        //        {
        //            helper.gameObj = (GameObject)gameObj;
        //            callback(helper);
        //            helper = null;
        //            return true;
        //        }
        Log.Fatlin("get dll path:" + Config.GetDllResPath(dllName));
//        LoadHelper helper = new LoadHelper(Config.GetDllResPath(dllName));
        return(GetRes(Config.GetDllResPath(dllName), callback, LoadPriority.High));
    }
示例#3
0
    /// <summary>
    /// 获取资源WWW 资源对象的方法.
    /// </summary>
    /// <returns>
    /// 是否可以立即获得资源,如果不能可能需要使用者自己先使用替代资源;
    /// </returns>
    public bool GetRes(string url, OnResLoadOK callback, LoadPriority param)
    {
        if (url != "")
        {
            /////先判断现在是否已经加载相应的资源可以使用;
            if (resCache.ContainsKey(url))
            {
                if (callback != null)
                {
                    callback(resCache[url]);
                }
                return(true);
            }
            else
            {
                //先看是否已经开始加载;
                for (int i = 0; i < loadingList.Count; i++)
                {
                    if (loadingList[i].Url == url)
                    {
                        if (callback != null)
                        {
                            if (loadingList[i].onLoadOK == null)
                            {
                                loadingList[i].onLoadOK = new OnResLoadOK(callback);
                            }
                            else
                            {
                                loadingList[i].onLoadOK += callback;
                            }
                        }
                        return(false);
                    }
                }

                //未加载资源则放入对应的待加载队列;
                LoadHelper newLoad = new LoadHelper(url, callback);
                newLoad.priority = param;
                switch (param)
                {
                case LoadPriority.Immediate:
                    RealLoad(newLoad);
                    break;

                case LoadPriority.High:
                    loadQueueHigh.Enqueue(newLoad);
                    break;

                case LoadPriority.Normal:
                    loadQueueNormal.Enqueue(newLoad);
                    break;

                default:
                    loadQueueLow.Enqueue(newLoad);
                    break;
                }
            }//处理不在资源缓存中的资源;

            //启动间隔repeatRate秒重复调用. wsy
            if (!IsInvoking("UpdateLoad"))
            {
                //Log.Wsy(string.Format("ResManager Start {0:f2}s Repeat:current time={1:f2}) ", repeatRate, Time.time));
                InvokeRepeating("UpdateLoad", 0.1f, repeatRate);
            }
        }
        return(false);
    }
示例#4
0
 public bool GetRes(string url, OnResLoadOK callback)
 {
     return(GetRes(url, callback, LoadPriority.Normal));
 }