HotPatchLaunchResources.cs 1.2 KB

12345678910111213141516171819202122232425262728
  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 => string.IsNullOrWhiteSpace(UnityEngine.Resources.Load<AppSettings>("AppSettings").DownloadUrl);
  20. public void InitializeEditor() => HotPatchService.InvokeInitialization(System.Reflection.Assembly.Load("AppRuntimes.Sources.Editor"));
  21. #endif
  22. }
  23. }