public Texture getAtalsTexture4Edit(string path) { string url = ""; #if UNITY_EDITOR url = "file://" + Application.dataPath + "/" + path; #endif WWW www = new WWW(Utl.urlAddTimes(url)); while (!www.isDone) { // new WaitForSeconds (0.05f); System.Threading.Thread.Sleep(50); //比较hacker的做法 } if (string.IsNullOrEmpty(www.error)) { Texture texture = www.texture; www.Dispose(); www = null; return(texture); } else { www.Dispose(); www = null; return(null); } }
/// <summary> /// Reads the new all text. 异步读取。优先从persistentDataPath目录取得,再从streamingAssetsPath读书 /// </summary> /// <returns>The new all text.</returns> /// <param name="fName">F name.</param> public static IEnumerator readNewAllTextAsyn(string fName, object OnGet) { string buff = ""; #if UNITY_WEBGL if (!CLCfgBase.self.isEditMode) { byte[] bytes = CLPreLoadRes4Webgl.getContent(fName); if (bytes != null) { buff = Encoding.UTF8.GetString(bytes); } } else { buff = readNewAllText(fName); } yield return(null); #else string fPath = CLPathCfg.persistentDataPath + "/" + fName; if (File.Exists(fPath)) { yield return(null); buff = File.ReadAllText(fPath); } else { fPath = Application.streamingAssetsPath + "/" + fName; if (Application.platform == RuntimePlatform.Android) { WWW www = new WWW(Utl.urlAddTimes(fPath)); yield return(www); buff = www.text; www.Dispose(); www = null; } else { yield return(null); if (File.Exists(fPath)) { buff = File.ReadAllText(fPath); } } } #if UNITY_EDITOR if (buff == null) { Debug.LogError("Get null content == " + fPath); } #endif #endif Utl.doCallback(OnGet, buff); }
/// <summary> /// Reads the new all text. 异步读取。优先从persistentDataPath目录取得,再从streamingAssetsPath读书 /// </summary> /// <returns>The new all text.</returns> /// <param name="fName">F name.</param> public static IEnumerator readNewAllBytesAsyn(string fName, object OnGet) { byte[] buff = null; string fPath = CLPathCfg.persistentDataPath + "/" + fName; if (File.Exists(fPath)) { yield return(null); buff = File.ReadAllBytes(fPath); } else { fPath = Application.streamingAssetsPath + "/" + fName; if (Application.platform == RuntimePlatform.Android) { WWW www = new WWW(Utl.urlAddTimes(fPath)); yield return(www); if (string.IsNullOrEmpty(www.error)) { buff = www.bytes; www.Dispose(); www = null; } } else { yield return(null); if (File.Exists(fPath)) { buff = File.ReadAllBytes(fPath); } } } #if UNITY_EDITOR if (buff == null) { Debug.LogWarning("Get null content == " + fPath); } #endif Utl.doCallback(OnGet, buff); }
/// <summary> /// Gets the server verver map.取得服务器版本文件的版本信息 /// </summary> static void getServerVerverMap() { string url = ""; //if (CLCfgBase.self.hotUpgrade4EachServer) //{ // //-- 说明是每个服务器单独处理更新控制 // url = PStr.begin().a(baseUrl).a("/").a(mVerverPath).a(".").a(verVerMD5).e(); //} //else //{ // url = PStr.begin().a(baseUrl).a("/").a(mVerverPath).e(); //} url = PStr.begin().a(baseUrl).a("/").a(mVerverPath).e(); WWWEx.get( Utl.urlAddTimes(url), //加了时间戳,保证一定会取得最新的 CLAssetType.bytes, (Callback)onGetServerVerverBuff, (Callback)onGetServerVerverBuff, null, true); }