private static bool CheckGldDownloadData(GLDDownloadData data) { if (data == null) { return(false); } if (string.IsNullOrEmpty(data.url) || string.IsNullOrEmpty(data.jsonPath) || string.IsNullOrEmpty(data.name)) { return(false); } return(true); }
private static IEnumerator DownloadGoogleSheet(GLDDownloadConfig config) { if (config != null && config.downLoadList.Count > 0) { for (int i = 0; i < config.downLoadList.Count; i++) { GLDDownloadData data = config.downLoadList[i]; if (data != null) { yield return(DownloadGoogleSheet(data)); } } } m_parser = null; AssetDatabase.Refresh(); }
public static void CreateTemplateDownloadConfig() { GLDDownloadConfig config = new GLDDownloadConfig(); GLDDownloadData data = new GLDDownloadData(); data.name = "template"; data.jsonPath = Path.Combine(Application.dataPath, "template.json"); data.csPath = Path.Combine(Application.dataPath, "template.cs"); data.url = "tempalte url"; config.downLoadList.Add(data); try { string path = DownloadConfigPath(); string json = JsonUtility.ToJson(config, true); File.WriteAllText(path, json); } catch (Exception e) { Debug.LogError(e); } }
private static IEnumerator DownloadGoogleSheet(GLDDownloadData data) { bool result = CheckGldDownloadData(data); if (result) { UnityWebRequest www = UnityWebRequest.Get(data.url); UnityWebRequestAsyncOperation async = www.SendWebRequest(); while (!async.isDone) { yield return(0); } if (string.IsNullOrEmpty(www.error)) { string text = www.downloadHandler.text; www.Dispose(); if (!string.IsNullOrEmpty(text)) { ParseCsvConfig(text, data.name, data.jsonPath, data.csPath); } else { Debug.LogError("Download text is null ! url : " + data.url); } } else { Debug.LogError(www.error); } } yield return(new WaitForEndOfFrame()); }