/// <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); }
public override void OnEndExcute() { if (IsSuccess()) { //更新数据库信息 CDBInstance localDB = DBVersionManager.GetLocalDBInstance(); DataBaseInfo info = DBVersionManager.GetDataInfo(path); switch (versionEnum) { case DBVersionEnum.Insert: DBVersionManager.InsertInfo(localDB, "unforceTable", new string[] { "'" + path + "'", "'" + info.md5 + "'", info.romote.ToString(), info.size.ToString() }); break; case DBVersionEnum.Update: DBVersionManager.UpdateInfo(localDB, "unforceTable", new string[] { "md5", "romote", "size" }, new string[] { "'" + info.md5 + "'", info.romote.ToString(), info.size.ToString() }, "path", "'" + path + "'"); break; } if (null != result && 0 < result.Length) { AssetBundle ab = AssetBundle.LoadFromMemory(result); target = ab.LoadAsset(name, typeof(AudioClip)) as AudioClip; Debug.LogError(target); } AysnResManager.Instance.AddAudio(path, target); AysnResManager.Instance.RemoveFromLoading(path); target = null; } base.OnEndExcute(); }
IEnumerator GetServerConfig() { Debug.Log("start link"); ///开始连接,获取配置表 WWW www = new WWW(ComTool.FormatTickUrl(URL_SERVER_CONFIG)); yield return(www); if (www.error == null) { string content = www.text; XmlDocument xml = new XmlDocument(); try { xml.LoadXml(content); Debug.LogError("get xml succsess"); XmlNode node = null; node = xml.SelectSingleNode("root/ChargeType"); Debug.LogError(" get id : " + node.Attributes.GetNamedItem("id").Value + " desc :" + node.Attributes.GetNamedItem("desc").Value); node = xml.SelectSingleNode("root/AssetUrl"); URL_SERVER_RES = node.Attributes.GetNamedItem("id").Value; } catch (Exception e) { Debug.LogError("xml format error:" + e.ToString());//xml格式错误 } www.Dispose(); } else { Debug.LogError("Config www net error:" + www.error);//网络请求失败 // StartCoroutine(StartCheck()); } //请求非强制资源配置 if (URL_SERVER_RES != "") { //获得资源配置表 WWW wwwXML = new WWW(ComTool.FormatTickUrl(URL_SERVER_RES + URL_SERVER_XML)); if (wwwXML.error == null) { string content = wwwXML.text; XmlDocument xml = new XmlDocument(); try { xml.LoadXml(content); DBVersionManager.SetServerXML(xml); AysnResManager.Instance.SetResUrl(URL_SERVER_RES); } catch (Exception e) { Debug.LogError("unforce xml format error:" + e.ToString());//xml格式错误 } wwwXML.Dispose(); } /// yield return(wwwXML); } }