// using System.Collections; // using System.Collections.Generic; // using UnityEngine; // using UnityEngine.Networking; // using Utility; // #if UNITY_WEBGL || UNITY_EDITOR // using WeChatWASM; // #endif // // public class WXDownload : Singleton // { // public void DownLoad(string url, string fileName, System.Action finish) // { // #if UNITY_WEBGL || UNITY_EDITOR // DownloadFileOption fileOption = new DownloadFileOption(); // fileOption.url = url; // fileOption.filePath = GetPluginCachePath() + "/" + fileName; // fileOption.fail = delegate(GeneralCallbackResult result) // { // Debug.LogError(url + "下载失败" + result.errMsg); // finish?.Invoke(false); // }; // fileOption.success = delegate(DownloadFileSuccessCallbackResult result) // { // finish?.Invoke(true); // // Debug.Log(url + "下载成功"); // }; // WX.DownloadFile(fileOption); // #elif UNITY_ANDROID // UnityWebRequest unityWebRequest = UnityWebRequest.Get(url); // unityWebRequest.downloadHandler = new DownloadHandlerBuffer(); // var unityWebRequestAsyncOperation = unityWebRequest.SendWebRequest(); // unityWebRequestAsyncOperation.completed += operation => // { // // if (unityWebRequest.result == UnityWebRequest.Result.Success) // { // finish?.Invoke(true); // } // else // { // Debug.LogError(url + "下载失败" + unityWebRequest.result); // finish?.Invoke(false); // } // // }; // #endif // } // public string GetCachePath(string url) // { // #if UNITY_WEBGL || UNITY_EDITOR // return WX.GetCachePath(url); // #elif UNITY_ANDROID // return url; // #endif // // } // // public string GetPluginCachePath() // { // #if UNITY_WEBGL || UNITY_EDITOR // return WX.PluginCachePath; // #elif UNITY_ANDROID // return Application.persistentDataPath; // #endif // } // }