/// <summary> /// 获取图片资源 /// </summary> /// <param name="path"></param> /// <returns></returns> public Texture2D GetTexture2D(string path) { if (mDicPool.ContainsKey(path))//已经在缓存中存在了 { return(mDicPool[path] as Texture2D); } if (IResManager.ResDebug) //调试模式下直接下载 { Texture2D texture2D = Resources.Load(path, typeof(Texture2D)) as Texture2D; mDicPool.Add(path, texture2D); return(texture2D); } //缓存不存在 那么看看是否在加载队列中 if (mListLoading.Contains(path)) { return(null); } //加载 DBVersionEnum versionEnum = DBVersionManager.CompareVersion(path); int index = path.LastIndexOf("/") + 1; string name = path.Substring(index, path.Length - index); if (versionEnum == DBVersionEnum.None) { //本地已经是最新的,那么从本地加载 AysnLoadTask task = new AysnLoadTask(); task.name = name; task.path = path; task.absolutePath = LocalUrl + "/" + path; mListLoading.Add(path); mLoadingTask.Add(task); } else //从服务器加载 { Texture2DMsg texture2DMsg = new Texture2DMsg(); texture2DMsg.name = path.Substring(index, path.Length - index); texture2DMsg.versionEnum = versionEnum; texture2DMsg.path = path; texture2DMsg.absolutePath = ResUrl + "/" + path; texture2DMsg.localPath = LocalUrl + "/" + path; texture2DMsg.SetUrl(texture2DMsg.absolutePath); CThreadManager.GetInstance().PushMsg(enumThreadID.enumThread_Web, texture2DMsg); mListLoading.Add(path); } return(null); }
void Update() { CThreadManager.GetInstance().OnGetMsg(); }