AppSettings.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. [UnityEngine.Scripting.APIUpdating.MovedFrom(true, sourceNamespace: "", sourceAssembly: "AppRuntimes", sourceClassName: "AppSettings")]
  3. public sealed class AppSettings : ScriptableObject
  4. {
  5. private static AppSettings instance;
  6. public static AppSettings Instance
  7. {
  8. get
  9. {
  10. if(!instance)
  11. {
  12. instance = Resources.Load<AppSettings>("AppSettings");
  13. }
  14. return instance;
  15. }
  16. }
  17. public string AppAddress = string.Empty;
  18. public string AppChannel = string.Empty;
  19. public string PrivacyUrl = string.Empty;
  20. [Tooltip("Absolute HTTP(S) URL of the hot patch resource directory or manifest.json")]
  21. public string DownloadUrl = string.Empty;
  22. [HideInInspector] public bool UseLocalHotPatchResources;
  23. [Tooltip("Hot patch assembly name, saved after selecting an asmdef in the AppSettings window")]
  24. public string HotPatchAssemblyName = string.Empty;
  25. [Tooltip("Game scene to open after loading the hot patch. Built as a separate scene AssetBundle and excluded from the Player scene list.")]
  26. public string GameSceneName = string.Empty;
  27. public static string RequireGameSceneName()
  28. {
  29. var settings = Resources.Load<AppSettings>("AppSettings");
  30. if (settings == null || string.IsNullOrWhiteSpace(settings.GameSceneName))
  31. throw new System.InvalidOperationException("Enter the game scene name in AppSettings and click Save.");
  32. return settings.GameSceneName.Trim();
  33. }
  34. public static string RequireHotPatchAssemblyName()
  35. {
  36. var settings = Resources.Load<AppSettings>("AppSettings");
  37. if (settings == null || string.IsNullOrWhiteSpace(settings.HotPatchAssemblyName))
  38. throw new System.InvalidOperationException("Select the hot patch assembly in AppSettings and click Save.");
  39. return settings.HotPatchAssemblyName;
  40. }
  41. }