private IEnumerator GetNetworkFiles() { //todo: change to UnityWebRequest var www = new WWW(Settings.UrlDownloadData); yield return(www); var jsonData = ""; if (string.IsNullOrEmpty(www.error)) { jsonData = System.Text.Encoding.UTF8.GetString(www.bytes, 3, www.bytes.Length - 3); // Skip thr first 3 bytes (i.e. the UTF8 BOM) // JSONObject works now var objDownloadData = MonoUtils.ConvertToObjDownloadData(jsonData); objDownloadData.Name = "Network Scene"; GameEvents.OnDownloadDataFinished(objDownloadData); } else { GameEvents.ErrorMessage(www.error); } GameEvents.OnFilesOpFinished(); }
IEnumerator LoadFilesData() { var info = new DirectoryInfo(_dirPath); var fileInfo = info.GetFiles(); foreach (var file in fileInfo) { if (!file.FullName.Contains(".json")) { continue; } Debug.Log(file.FullName); var data = File.ReadAllText(file.FullName); var objDownloadData = MonoUtils.ConvertToObjDownloadData(data); objDownloadData.Name = file.Name; GameEvents.OnDownloadDataFinished(objDownloadData); } yield return(null); GameEvents.OnFilesOpFinished(); }