mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
TODO(Bepis): commit your UnityChainloader patch
`git rebase -i` edit this and `git commit --amend --reset-author` once you're happy with it
This commit is contained in:
1 parent
fa9b1ab9d1
commit
becda82148
1 file changed
+46
-14
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -10,6 +11,7 @@ using BepInEx.Unity.Logging;
|
||||
using MonoMod.Utils;
|
||||
using UnityEngine;
|
||||
using Logger = BepInEx.Logging.Logger;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace BepInEx.Unity.Bootstrap;
|
||||
|
||||
@@ -50,29 +52,59 @@ public class UnityChainloader : BaseChainloader<BaseUnityPlugin>
|
||||
get => Application.unityVersion;
|
||||
}
|
||||
|
||||
private static void StaticStart(string gameExePath = null)
|
||||
[Obsolete("This method is public due to a limitation with Unity 4.x. DO NOT CALL", true)]
|
||||
public static void StaticStart(string gameExePath = null)
|
||||
{
|
||||
var instance = new UnityChainloader();
|
||||
instance.Initialize(gameExePath);
|
||||
instance.Execute();
|
||||
try
|
||||
{
|
||||
Logger.Log(LogLevel.Debug, "Entering chainloader StaticStart");
|
||||
|
||||
var instance = new UnityChainloader();
|
||||
instance.Initialize(gameExePath);
|
||||
instance.Execute();
|
||||
|
||||
Logger.Log(LogLevel.Debug, "Exiting chainloader StaticStart");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log(LogLevel.Fatal, $"Unable to complete chainloader StaticStart: {ex.Message}");
|
||||
Logger.Log(LogLevel.Fatal, ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Initialize(string gameExePath = null)
|
||||
{
|
||||
UnityTomlTypeConverters.AddUnityEngineConverters();
|
||||
try
|
||||
{
|
||||
Logger.Log(LogLevel.Debug, "Entering chainloader initialize");
|
||||
|
||||
ThreadingHelper.Initialize();
|
||||
UnityTomlTypeConverters.AddUnityEngineConverters();
|
||||
|
||||
ManagerObject = new GameObject("BepInEx_Manager") { hideFlags = HideFlags.HideAndDontSave };
|
||||
Object.DontDestroyOnLoad(ManagerObject);
|
||||
Logger.Log(LogLevel.Debug, "Initializing ThreadingHelper");
|
||||
//ThreadingHelper.Initialize();
|
||||
|
||||
var productNameProp =
|
||||
typeof(Application).GetProperty("productName", BindingFlags.Public | BindingFlags.Static);
|
||||
_consoleTitle =
|
||||
$"{CurrentAssemblyName} {CurrentAssemblyVersion} - {productNameProp?.GetValue(null, null) ?? Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().ProcessName)}";
|
||||
Logger.Log(LogLevel.Debug, "Creating Manager object");
|
||||
ManagerObject = new GameObject("BepInEx_Manager") { hideFlags = HideFlags.HideAndDontSave };
|
||||
Object.DontDestroyOnLoad(ManagerObject);
|
||||
|
||||
base.Initialize(gameExePath);
|
||||
Logger.Log(LogLevel.Debug, "Getting game product name");
|
||||
var productNameProp =
|
||||
typeof(Application).GetProperty("productName", BindingFlags.Public | BindingFlags.Static);
|
||||
_consoleTitle =
|
||||
$"{CurrentAssemblyName} {CurrentAssemblyVersion} - {productNameProp?.GetValue(null, null) ?? Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().ProcessName)}";
|
||||
|
||||
Logger.Log(LogLevel.Debug, "Falling back to BaseChainloader initializer");
|
||||
|
||||
base.Initialize(gameExePath);
|
||||
|
||||
Logger.Log(LogLevel.Debug, "Exiting chainloader initialize");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log(LogLevel.Fatal, $"Unable to complete chainloader init: {ex.Message}");
|
||||
Logger.Log(LogLevel.Fatal, ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void InitializeLoggers()
|
||||
|
||||
Reference in new issue
Block a user