summaryrefslogtreecommitdiff
path: root/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDKUpdater.cs
diff options
context:
space:
mode:
authortylermurphy534 <tylermurphy534@gmail.com>2022-11-06 15:12:42 -0500
committertylermurphy534 <tylermurphy534@gmail.com>2022-11-06 15:12:42 -0500
commiteb84bb298d2b95aec7b2ae12cbf25ac64f25379a (patch)
treeefd616a157df06ab661c6d56651853431ac6b08b /VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDKUpdater.cs
downloadunityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.gz
unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.bz2
unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.zip
move to self host
Diffstat (limited to 'VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDKUpdater.cs')
-rw-r--r--VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDKUpdater.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDKUpdater.cs b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDKUpdater.cs
new file mode 100644
index 00000000..0be3003a
--- /dev/null
+++ b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDKUpdater.cs
@@ -0,0 +1,70 @@
+using UnityEngine;
+using System.Collections;
+using UnityEditor;
+
+public class SDKUpdater : MonoBehaviour
+{
+ static string GetCurrentVersion()
+ {
+ string currentVersion = "";
+ string versionTextPath = Application.dataPath + "/VRCSDK/version.txt";
+ if(System.IO.File.Exists(versionTextPath))
+ {
+ string[] versionFileLines = System.IO.File.ReadAllLines(versionTextPath);
+ if(versionFileLines.Length > 0)
+ currentVersion = versionFileLines[0];
+ }
+ return currentVersion;
+ }
+
+ [MenuItem("VRChat SDK/Utilities/Check For Updates")]
+ static void CheckForUpdatesWithProgressBar()
+ {
+ CheckForUpdates(false);
+ }
+
+ public static void CheckForUpdates(bool isSilent = true)
+ {
+ Debug.Log("Checking for VRChat SDK updates...");
+ if(!isSilent)
+ EditorUtility.DisplayProgressBar("SDK Updater", "Checking for updates...", 1f);
+
+ VRC.Core.ConfigManager.RemoteConfig.Init(delegate() {
+ string currentSdkVersion = GetCurrentVersion();
+ string sdkVersion = VRC.Core.ConfigManager.RemoteConfig.GetString("devSdkVersion");
+ string sdkUrl = VRC.Core.ConfigManager.RemoteConfig.GetString("devSdkUrl");
+ EditorUtility.ClearProgressBar();
+
+ if(sdkVersion == currentSdkVersion)
+ {
+ ShowDownloadUpdatePopup(false, currentSdkVersion, sdkUrl, isSilent);
+ }
+ else
+ {
+ ShowDownloadUpdatePopup(true, sdkVersion, sdkUrl, isSilent);
+ }
+ });
+ }
+
+ static void ShowDownloadUpdatePopup(bool updateAvailable, string latestVersion, string sdkUrl, bool isSilent)
+ {
+ if(!updateAvailable)
+ {
+ if(!isSilent)
+ EditorUtility.DisplayDialog("VRChat SDK Updater", "SDK is up to date (version " + latestVersion + ")", "Okay");
+ }
+ else
+ {
+ if(EditorUtility.DisplayDialog("VRChat SDK Updater", "An update is available (version " + latestVersion + ")", "Download", "Cancel"))
+ {
+ DownloadUpdate(sdkUrl);
+ }
+ }
+ }
+
+ static void DownloadUpdate(string sdkUrl)
+ {
+ Application.OpenURL(sdkUrl);
+ }
+
+}