From f29137400b74d9a1debb879c3f148d0223a7dcd6 Mon Sep 17 00:00:00 2001 From: Joshuarox100 <12418573+Joshuarox100@users.noreply.github.com> Date: Thu, 19 May 2022 17:18:56 -0500 Subject: [PATCH] Initial commit, plus 1.3.3 fix. - Made auto-updater work correctly. --- CHANGES.md | 6 ++-- Editor/VERSION | 2 +- Engine/Scripts/AutoUpdater.cs | 55 ++++++++++++++++++++++++++++------- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6cad0c3..0d0283b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,9 @@ -# v1.3.2 -Minor update for the code to use the value given by the VRCSDK for max parameter space. Also ceased reliance on the SDK's controller templates and instead refer to included ones for the future. +# v1.3.3 +Important bug-fix for the auto-updater so it receives new versions correctly. If you are currently on v1.3.2, you will not receive automatic updates because of it. Sincerest apologies for the inconvenience. ## Fixes +### v1.3.3 +- Fixed a *bit* of an oversight with the updater changes. ### v1.3.2 - Added preliminary support for arbitrary parameter space in the UI. - Default controller templates and animations are now included in II. diff --git a/Editor/VERSION b/Editor/VERSION index ba9cbde..0f36c97 100644 --- a/Editor/VERSION +++ b/Editor/VERSION @@ -1,2 +1,2 @@ -v1.3.2 +v1.3.3 2019.4 \ No newline at end of file diff --git a/Engine/Scripts/AutoUpdater.cs b/Engine/Scripts/AutoUpdater.cs index c54a8d5..6f3e8de 100644 --- a/Engine/Scripts/AutoUpdater.cs +++ b/Engine/Scripts/AutoUpdater.cs @@ -42,7 +42,7 @@ static void OnInit() public class Updater : UnityEngine.Object { // MonoBehaviour for running network coroutines. - private class NetworkManager : MonoBehaviour + private class NetworkManager : MonoBehaviour { // Gets a desired request from the internet public static IEnumerator GetFileRequest(string url, string filePath, Action callback) @@ -61,8 +61,7 @@ public static IEnumerator GetText(string url, Action result) if (www.isNetworkError || www.isHttpError) { - if (!www.error.Contains("404")) - Debug.LogError(www.error); + Debug.LogError(www.error); result?.Invoke(""); } else @@ -133,26 +132,62 @@ public static bool CheckForUpdates(bool auto = false) // Run a coroutine to retrieve the GitHub data. NetworkManager manager = temp.AddComponent(); - manager.StartCoroutine(NetworkManager.GetText("https://raw.githubusercontent.com/Joshuarox100/VRC-Inventory-Inventor/master/Editor/VPM", latestVersion => - { + manager.StartCoroutine(NetworkManager.GetText("https://raw.githubusercontent.com/Joshuarox100/VRC-Inventory-Inventor/master/Editor/VERSION", latestVersion => { string[] decodedVersion = latestVersion.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); + string latestBuild = ""; + string latestUnity = ""; + if (decodedVersion.Length > 0) + latestBuild = decodedVersion[0]; + if (decodedVersion.Length > 1) + latestUnity = decodedVersion[1]; + + string vpmBuild = ""; + string vpmUnity = ""; + if (decodedVersion.Length > 4) + vpmBuild = decodedVersion[4]; + if (decodedVersion.Length > 5) + vpmUnity = decodedVersion[5]; // Network Error. if (latestVersion == "" && !auto) { - EditorUtility.DisplayDialog("Inventory Inventor", "You are using the latest version.", "Close"); + EditorUtility.DisplayDialog("Inventory Inventor", "Failed to fetch the latest version.\n(Check console for details.)", "Close"); + } + // VPM is now required. + else if (vpmBuild != "") + { + if (EditorUtility.DisplayDialog("Inventory Inventor", "A newer version (" + vpmBuild + ") is available, but it is only usable if you migrate your project to use the VRChat Creator Companion.\nOpen GitHub to Download the Package?" + (auto ? "\n(You can disable update checks within Project Settings)" : ""), "Yes", "No")) + Application.OpenURL("https://github.com/Joshuarox100/VRC-Inventory-Inventor"); + } + // VERSION file missing. + else if (buildVersion == "" && !auto) + { + EditorUtility.DisplayDialog("Inventory Inventor", "Failed to identify installed version.\n(VERSION file was not found.)", "Close"); + } + // Project has been archived. + else if (latestVersion == "RIP" && !auto) + { + EditorUtility.DisplayDialog("Inventory Inventor", "Project has been put on hold indefinitely.", "Close"); } // An update is available. - else if (latestVersion != "") + else if (buildVersion != "" && buildVersion != latestBuild) { - if (EditorUtility.DisplayDialog("Inventory Inventor", "A newer version is available, but it is only usable if you migrate your project to use the VRChat Creator Companion.\nOpen GitHub to Download the Package?" + (auto ? "\n(You can disable update checks within Project Settings)" : ""), "Yes", "No")) + if ((unityVersion != latestUnity && EditorUtility.DisplayDialog("Inventory Inventor", "A new update is available, but for a newer version of Unity (" + latestUnity + ").\nInstall anyway? (Only do this before migrating!)" + (auto ? "\n(You can disable update checks within Project Settings)" : ""), "Yes", "No")) + || (unityVersion == latestUnity && EditorUtility.DisplayDialog("Inventory Inventor", "A new update is available! (" + latestBuild + ")\nDownload and install from GitHub?" + (auto ? "\n(You can disable update checks within Project Settings)" : ""), "Yes", "No"))) { - Application.OpenURL("https://github.com/Joshuarox100/VRC-Inventory-Inventor"); + // Download the update. + DownloadUpdate(latestBuild); + updated = true; } } + // Using latest version. + else if (!auto) + { + EditorUtility.DisplayDialog("Inventory Inventor", "You are using the latest version.", "Close"); + } DestroyImmediate(temp); })); - return false; + return updated; } // Downloads and installs a given version of the package.