private IEnumerator _downloadCustomPlatform(platformDownloadData downloadData) { using (UnityWebRequest www = UnityWebRequest.Get(downloadData.download)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Console.WriteLine(www.error); } else { string customPlatformsFolderPath = Path.Combine(Environment.CurrentDirectory, "CustomPlatforms", downloadData.name); System.IO.File.WriteAllBytes(@customPlatformsFolderPath + ".plat", www.downloadHandler.data); try { CustomFloorPlugin.PlatformManager.AddPlatform(customPlatformsFolderPath + ".plat"); } catch (Exception ex) { Logging.logger.Error($"Failed to add Platform {customPlatformsFolderPath}.plat \n {ex}"); } } } }
private IEnumerator _downloadCustomPlatform(platformDownloadData downloadData) { using (UnityWebRequest www = UnityWebRequest.Get(downloadData.download)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Console.WriteLine(www.error); } else { string customPlatformsFolderPath = Path.Combine(Environment.CurrentDirectory, "CustomPlatforms", downloadData.name); System.IO.File.WriteAllBytes(@customPlatformsFolderPath + ".plat", www.downloadHandler.data); //refreshPlatforms(); } } }
private IEnumerator downloadCustomPlatform(string hash, string name) { using (UnityWebRequest www = UnityWebRequest.Get("https://modelsaber.assistant.moe/api/v1/platform/get.php?filter=hash:" + hash)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Console.WriteLine(www.error); } else { platformDownloadData downloadData = JsonUtility.FromJson <platformDownloadData>(JSON.Parse(www.downloadHandler.text)[0].ToString()); if (downloadData.name == name) { StartCoroutine(_downloadCustomPlatform(downloadData)); } } } }
private IEnumerator downloadCustomPlatform(string hash, string name) { using (UnityWebRequest www = UnityWebRequest.Get("https://modelsaber.com/api/v1/platform/get.php?filter=hash:" + hash)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Console.WriteLine(www.error); } else { var downloadData = JsonConvert.DeserializeObject <Dictionary <string, platformDownloadData> >(www.downloadHandler.text); platformDownloadData data = downloadData.FirstOrDefault().Value; if (data != null) { if (data.name == name) { SharedCoroutineStarter.instance.StartCoroutine(_downloadCustomPlatform(data)); } } } } }