private bool IsNewUpdate(AutoUpdaterJSON data) { Version newVer = Version.Parse(data.latestVersion); Version currentVer = Version.Parse(Application.version); if (newVer.Build > currentVer.Build && newVer.Minor >= currentVer.Minor && newVer.Major >= currentVer.Major) { return(true); } else if (newVer.Minor > currentVer.Minor && newVer.Major >= currentVer.Major) { return(true); } else if (newVer.Major > currentVer.Major) { return(true); } return(false); }
public IEnumerator DoUpdate(AutoUpdaterJSON data) { downloadSlider.gameObject.SetActive(true); if (Application.isEditor) { downloadText.SetText("Editor build detected, skipping install process."); yield return(new WaitForSeconds(2f)); Application.Quit(); yield break; } downloadText.SetText("Downloading..."); UnityWebRequest www = UnityWebRequest.Get(data.downloadLink); string savePath = Path.Combine(Application.dataPath, @"..\", "update.zip"); www.downloadHandler = new DownloadHandlerFile(savePath); var operation = www.SendWebRequest(); while (!operation.isDone) { downloadSlider.currentPercent = operation.progress * 100f; yield return(null); } if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log("File successfully downloaded and saved to " + savePath); downloadSlider.currentPercent = 100; downloadText.SetText("Download complete, installing..."); } //Launch unzipper www.downloadHandler.Dispose(); www.Dispose(); yield return(new WaitForSeconds(2f)); Process.Start(Path.Combine(Application.streamingAssetsPath, "Installer", "NotReaperInstaller.exe")); Application.Quit(); }
private bool IsIgnoringUpdate(AutoUpdaterJSON data) { if (data.latestVersion == PlayerPrefs.GetString("ignoredVersion")) { return(true); } else { return(false); } }
private void HandleUpdate(AutoUpdaterJSON data) { if (!IsNewUpdate(data)) { return; } if (IsIgnoringUpdate(data)) { return; } UpdaterWindow.I.gameObject.SetActive(true); UpdaterWindow.I.Activate(data); }
private IEnumerator Init() { string url = "https://raw.githubusercontent.com/CircuitLord/NotReaper/master/updates.json"; UnityWebRequest www = UnityWebRequest.Get(url); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { updateData = JsonUtility.FromJson <AutoUpdaterJSON>(www.downloadHandler.text); HandleUpdate(updateData); } }