SHA256
Initial Commit
This commit is contained in:
commit
44a22ae103
19 files changed
+772
No files matched your search
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using ADOFAIRenderer;
|
||||
using ADOFAIRenderer.Component;
|
||||
using ADOFAIRenderer.Util;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
[assembly: MelonInfo(typeof(RenderMod), "ADOFAI Renderer", "0.0.1-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!;
|
||||
public static AssetBundle SceneBundle = null!;
|
||||
public static bool WatchGameLoaded;
|
||||
public static string[] ModScenes = {};
|
||||
|
||||
private static double _beforeTime = 0;
|
||||
|
||||
public static bool IsRendering = false;
|
||||
public static bool IsCapturing = false;
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
var renderManagerObj = new GameObject("Render Manager");
|
||||
var updateHookerObj = new GameObject("Update Hooker");
|
||||
Object.DontDestroyOnLoad( renderManagerObj );
|
||||
Object.DontDestroyOnLoad( updateHookerObj );
|
||||
|
||||
renderManagerObj.AddComponent<RenderManager>();
|
||||
updateHookerObj.AddComponent<FirstUpdate>();
|
||||
LoadBundles();
|
||||
}
|
||||
|
||||
private static void LoadBundles()
|
||||
{
|
||||
FontBundle = BundleLoader.GetBundle("fonts");
|
||||
SceneBundle = BundleLoader.GetBundle("scenes");
|
||||
ModScenes = SceneBundle.GetAllScenePaths();
|
||||
}
|
||||
|
||||
public static void FixEventSystem()
|
||||
{
|
||||
if (EventSystem.current == null) return;
|
||||
var currentModule = EventSystem.current.currentInputModule;
|
||||
|
||||
if (currentModule != null) return;
|
||||
MelonLogger.Msg("Unity 6 인풋 모듈 이식.");
|
||||
|
||||
var newModule = EventSystem.current.gameObject.AddComponent<StandaloneInputModule>();
|
||||
newModule.enabled = true;
|
||||
}
|
||||
|
||||
public static void OnFirstUpdate()
|
||||
{
|
||||
if (_beforeTime == 0) _beforeTime = Time.realtimeSinceStartupAsDouble;
|
||||
|
||||
var realDeltaTime = Time.realtimeSinceStartupAsDouble - _beforeTime;
|
||||
_beforeTime = Time.realtimeSinceStartupAsDouble;
|
||||
|
||||
if (!IsRendering) return;
|
||||
RenderManager.FrameCount++;
|
||||
|
||||
Time.timeScale = (float)(Time.deltaTime / realDeltaTime);
|
||||
}
|
||||
|
||||
public static void StartRender()
|
||||
{
|
||||
var targetMethod = typeof(scnEditor).GetMethod("TryApplicationQuit",
|
||||
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
|
||||
|
||||
if (targetMethod == null || scnEditor.instance == null) return;
|
||||
if (ADOBase.levelPath.IsNullOrEmpty())
|
||||
{
|
||||
scnEditor.instance.TryQuitToMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
RenderManager.LevelPath = ADOBase.levelPath;
|
||||
|
||||
scnEditor.instance.CheckUnsavedChanges(() =>
|
||||
{
|
||||
var quitDelegate =
|
||||
(Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), scnEditor.instance, targetMethod);
|
||||
|
||||
Application.wantsToQuit -= quitDelegate;
|
||||
ADOBase.loader.LoadSceneWithTransition(WipeDirection.StartsFromRight, "Assets/Scenes/RenderSettingsScene.unity");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user