/// <summary> /// request image /// </summary> /// <param name="url">image url,like 'http://www.my-server.com/image.png '</param> /// <param name="onSuccess">callback</param> /// <param name="onFail">callback</param> /// <param name="isTexture2dReadable">texture2d readonly</param> /// <returns></returns> public IEnumerator GetTextureEncrypted_CO(string url, Action <Texture2D> onSuccess, Action <string> onFail, bool isTexture2dReadable) { UnityWebRequest uwr = UnityWebRequest.Get(url + ".txt"); yield return(uwr.SendWebRequest()); if (!(uwr.isNetworkError || uwr.isHttpError)) { Texture2D texture2d = new Texture2D(2, 2, TextureFormat.RGBA32, false); texture2d.wrapMode = TextureWrapMode.Clamp; byte[] bytes = ResourcesManager.ReverseBytes(uwr.downloadHandler.data); texture2d.LoadImage(bytes, !isTexture2dReadable); onSuccess?.Invoke(texture2d); } else { onFail?.Invoke(uwr.error); } uwr.Dispose(); }
private void LoadLocalizeString() { _dicLocalizeString.Clear(); string url = string.Format("TextScript/{0}/Localization", _listLocalizeType[_localizeTypeIndex]); ResourcesManager.Asset tAsset = new ResourcesManager.Asset(url, ResourcesManager.AssetType.Bytes, ResourcesManager.AssetPath.Resources); ResourcesManager.LoadAsset(tAsset, (ResourcesManager.Asset asset) => { byte[] bytes = asset._bytes; FileHandler handler = new FileHandler(bytes); string str; while (!string.IsNullOrEmpty(str = handler.ReadLine())) { string[] strs = str.Split('='); string key = strs[0].Trim(); if (key.Substring(0, 2).Equals("//")) { continue; } key = key.Substring(1, key.Length - 2); string value = strs[1].Trim(); value = value.Substring(1, value.Length - 3); if (_dicLocalizeString.ContainsKey(key)) { _dicLocalizeString[key] = value; } else { _dicLocalizeString.Add(key, value); } if (null != OnLocalize) { OnLocalize.Invoke(); } } }, (ResourcesManager.Asset asset) => { }); }