SteamVR_Windows_Editor_Helper.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace Valve.VR
  4. {
  5. public class SteamVR_Windows_Editor_Helper
  6. {
  7. public enum BrowserApplication
  8. {
  9. Unknown,
  10. InternetExplorer,
  11. Firefox,
  12. Chrome,
  13. Opera,
  14. Safari,
  15. Edge,
  16. }
  17. public static BrowserApplication GetDefaultBrowser()
  18. {
  19. #if UNITY_EDITOR
  20. #if UNITY_STANDALONE_WIN
  21. const string userChoice = @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice";
  22. using (Microsoft.Win32.RegistryKey userChoiceKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(userChoice))
  23. {
  24. if (userChoiceKey == null)
  25. {
  26. return BrowserApplication.Unknown;
  27. }
  28. object progIdValue = userChoiceKey.GetValue("Progid");
  29. if (progIdValue == null)
  30. {
  31. return BrowserApplication.Unknown;
  32. }
  33. string browserId = progIdValue.ToString().ToLower();
  34. if (browserId.Contains("ie.http"))
  35. return BrowserApplication.InternetExplorer;
  36. else if (browserId.Contains("firefox"))
  37. return BrowserApplication.Firefox;
  38. else if (browserId.Contains("chrome"))
  39. return BrowserApplication.Chrome;
  40. else if (browserId.Contains("opera"))
  41. return BrowserApplication.Opera;
  42. else if (browserId.Contains("safari"))
  43. return BrowserApplication.Safari;
  44. else if (browserId.Contains("appcq0fevzme2pys62n3e0fbqa7peapykr8v")) //AppXq0fevzme2pys62n3e0fbqa7peapykr8v
  45. return BrowserApplication.Edge;
  46. else
  47. return BrowserApplication.Unknown;
  48. }
  49. #else
  50. return BrowserApplication.Firefox;
  51. #endif
  52. #else
  53. return BrowserApplication.Firefox;
  54. #endif
  55. }
  56. }
  57. }