multiple xr toolkit package
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SDKUpdater.cs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4. public class SDKUpdater : MonoBehaviour
  5. {
  6. static string GetCurrentVersion()
  7. {
  8. string currentVersion = "";
  9. string versionTextPath = Application.dataPath + "/VRCSDK/version.txt";
  10. if(System.IO.File.Exists(versionTextPath))
  11. {
  12. string[] versionFileLines = System.IO.File.ReadAllLines(versionTextPath);
  13. if(versionFileLines.Length > 0)
  14. currentVersion = versionFileLines[0];
  15. }
  16. return currentVersion;
  17. }
  18. [MenuItem("VRChat SDK/Utilities/Check For Updates")]
  19. static void CheckForUpdatesWithProgressBar()
  20. {
  21. CheckForUpdates(false);
  22. }
  23. public static void CheckForUpdates(bool isSilent = true)
  24. {
  25. Debug.Log("Checking for VRChat SDK updates...");
  26. if(!isSilent)
  27. EditorUtility.DisplayProgressBar("SDK Updater", "Checking for updates...", 1f);
  28. VRC.Core.RemoteConfig.Init(delegate() {
  29. string currentSdkVersion = GetCurrentVersion();
  30. string sdkVersion = VRC.Core.RemoteConfig.GetString("devSdkVersion");
  31. string sdkUrl = VRC.Core.RemoteConfig.GetString("devSdkUrl");
  32. EditorUtility.ClearProgressBar();
  33. if(sdkVersion == currentSdkVersion)
  34. {
  35. ShowDownloadUpdatePopup(false, currentSdkVersion, sdkUrl, isSilent);
  36. }
  37. else
  38. {
  39. ShowDownloadUpdatePopup(true, sdkVersion, sdkUrl, isSilent);
  40. }
  41. });
  42. }
  43. static void ShowDownloadUpdatePopup(bool updateAvailable, string latestVersion, string sdkUrl, bool isSilent)
  44. {
  45. if(!updateAvailable)
  46. {
  47. if(!isSilent)
  48. EditorUtility.DisplayDialog("VRChat SDK Updater", "SDK is up to date (version " + latestVersion + ")", "Okay");
  49. }
  50. else
  51. {
  52. if(EditorUtility.DisplayDialog("VRChat SDK Updater", "An update is available (version " + latestVersion + ")", "Download", "Cancel"))
  53. {
  54. DownloadUpdate(sdkUrl);
  55. }
  56. }
  57. }
  58. static void DownloadUpdate(string sdkUrl)
  59. {
  60. Application.OpenURL(sdkUrl);
  61. }
  62. }