using System; using System.Threading; using Cysharp.Threading.Tasks; namespace HotPatch { public sealed class HotPatchLaunchResources : ILaunchResources { public string GameSceneName => AppSettings.RequireGameSceneName(); public string LoadedScenePath => HotPatchService.LoadedScenePath; public string LoadedVersion => HotPatchService.LoadedVersion; public bool HasLoadedAssembly => HotPatchService.LoadedAssembly != null; public bool RequiresRestart => HotPatchService.RequiresRestart; public async UniTask LoadAsync(Action progress, CancellationToken cancellationToken) { await HotPatchService.LoadAndInitializeAsync(value => progress?.Invoke(value.Stage, value.Value), cancellationToken); } public void MarkEntryFailed() => HotPatchService.MarkEntryFailed(); #if UNITY_EDITOR public bool UseEditorSceneLoading { get { var settings = UnityEngine.Resources.Load("AppSettings"); return !settings.UseLocalHotPatchResources && string.IsNullOrWhiteSpace(settings.DownloadUrl); } } public void InitializeEditor() => HotPatchService.InvokeInitialization(System.Reflection.Assembly.Load("AppRuntimes.Sources.Editor")); #endif } }