| 1234567891011121314151617181920212223242526272829303132333435 |
- #if UNITY_EDITOR
- using System;
- using System.Reflection;
- using System.Threading;
- using Cysharp.Threading.Tasks;
- using UnityEngine;
- // Editor-local source adapter for this modular game; never replaces the Player hot-patch provider.
- internal sealed class EditorLocalGameResources : ILaunchResources
- {
- public string GameSceneName => "Main";
- public string LoadedScenePath => "Assets/DevilLink2/Scenes/Main.unity";
- public string LoadedVersion => "editor-modular-local";
- public bool HasLoadedAssembly => false;
- public bool RequiresRestart => false;
- public bool UseEditorSceneLoading => true;
- public void MarkEntryFailed() { }
- static Type Installer => Type.GetType("DevilLink2.UI.MainUIInstaller, DevilLink2");
- public UniTask LoadAsync(Action<string,float> progress, CancellationToken token)
- {
- token.ThrowIfCancellationRequested();
- if(UnityEditor.EditorApplication.isCompiling)throw new InvalidOperationException("Wait for Unity script compilation to finish, then RETRY.");
- if(Installer==null)throw new InvalidOperationException("MainUIInstaller is unavailable in the DevilLink2 assembly. Resolve Unity compilation errors, then RETRY.");
- if(!UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEditor.SceneAsset>(LoadedScenePath))throw new InvalidOperationException("Local Main scene is missing: "+LoadedScenePath);
- progress?.Invoke("Preparing local game scene",0);
- return UniTask.CompletedTask;
- }
- public void InitializeEditor()
- {
- var method=Installer?.GetMethod("InstallMain",BindingFlags.NonPublic|BindingFlags.Static);
- if(method==null)throw new MissingMethodException("MainUIInstaller.InstallMain is unavailable.");
- method.Invoke(null,null); // Same game initializer, with its own once-only and save-recovery guards.
- }
- }
- #endif
|