using ADOFAIRenderer; using ADOFAIRenderer.Core; using ADOFAIRenderer.Util; using FFmpeg.AutoGen; using MelonLoader; using MelonLoader.Utils; using UnityEngine; using UnityEngine.EventSystems; [assembly: MelonInfo(typeof(RenderMod), "ADOFAI Renderer", "0.0.5-INDEV", "ADOFAI Editor Forum")] [assembly: MelonGame("7th Beat Games", "A Dance of Fire and Ice")] namespace ADOFAIRenderer { public class RenderMod : MelonMod { public static AssetBundle FontBundle = null!; // ReSharper disable once MemberCanBePrivate.Global public static AssetBundle SceneBundle = null!; // ReSharper disable once MemberCanBePrivate.Global public static AssetBundle ShaderBundle = null!; public static ComputeShader ColorConversionShader = null!; public static bool IsFeatureDisabled = false; public override void OnInitializeMelon() { ffmpeg.RootPath = MelonEnvironment.UserLibsDirectory; var renderManagerObj = new GameObject("Render Manager"); var updateHookerObj = new GameObject("Update Hooker"); Object.DontDestroyOnLoad(renderManagerObj); Object.DontDestroyOnLoad(updateHookerObj); renderManagerObj.AddComponent(); updateHookerObj.AddComponent(); LoadBundles(); } private static void LoadBundles() { FontBundle = BundleLoader.GetBundle("fonts"); SceneBundle = BundleLoader.GetBundle("scenes"); SceneBundle.GetAllScenePaths(); try { ShaderBundle = BundleLoader.GetBundle("shaders"); ColorConversionShader = ShaderBundle.LoadAsset("ColorConversion"); Melon.Logger.Msg("컬러 변환 Compute Shader 로드 완료."); } catch (System.Exception ex) { Melon.Logger.Warning($"Shader 에셋번들을 로드할 수 없습니다. GPU 컬러 변환이 비활성화되며 CPU로 폴백합니다. 에러: {ex.Message}"); } } public static void FixEventSystem() { if (EventSystem.current == null) return; var currentModule = EventSystem.current.currentInputModule; if (currentModule != null) return; Melon.Logger.Msg("Unity 6 인풋 모듈 이식."); var newModule = EventSystem.current.gameObject.AddComponent(); newModule.enabled = true; } public override void OnApplicationQuit() { if (RenderManager.Instance == null) return; Melon.Logger.Msg("MelonLoader 종료 감지: RenderManager의 활성 프로세스를 강제 수거 및 종료합니다."); RenderManager.Instance.CleanUpActiveRender(); } } }