HotPatchLaunchResources.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Threading;
  3. using Cysharp.Threading.Tasks;
  4. namespace HotPatch
  5. {
  6. public sealed class HotPatchLaunchResources : ILaunchResources
  7. {
  8. public string GameSceneName => AppSettings.RequireGameSceneName();
  9. public string LoadedScenePath => HotPatchService.LoadedScenePath;
  10. public string LoadedVersion => HotPatchService.LoadedVersion;
  11. public bool HasLoadedAssembly => HotPatchService.LoadedAssembly != null;
  12. public bool RequiresRestart => HotPatchService.RequiresRestart;
  13. public async UniTask LoadAsync(Action<string, float> progress, CancellationToken cancellationToken)
  14. {
  15. await HotPatchService.LoadAndInitializeAsync(value => progress?.Invoke(value.Stage, value.Value), cancellationToken);
  16. }
  17. public void MarkEntryFailed() => HotPatchService.MarkEntryFailed();
  18. #if UNITY_EDITOR
  19. public bool UseEditorSceneLoading
  20. {
  21. get
  22. {
  23. var settings = UnityEngine.Resources.Load<AppSettings>("AppSettings");
  24. return !settings.UseLocalHotPatchResources && string.IsNullOrWhiteSpace(settings.DownloadUrl);
  25. }
  26. }
  27. public void InitializeEditor() => HotPatchService.InvokeInitialization(System.Reflection.Assembly.Load("AppRuntimes.Sources.Editor"));
  28. #endif
  29. }
  30. }