Refactor Unity -> UnityMono

Use runtime names for BepInEx modules instead of just the game engine
This commit is contained in:
ghorsington committed 2022-08-14 17:19:08 +03:00
1 parent 46d9dd4f62
commit f400445ba1
23 files changed
+46 -40

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("BepInEx.Preloader.Core")]
[assembly: InternalsVisibleTo("BepInEx.Unity")]
[assembly: InternalsVisibleTo("BepInEx.UnityMono")]
[assembly: InternalsVisibleTo("BepInEx.NetLauncher")]
[assembly: InternalsVisibleTo("BepInEx.NetCore")]
[assembly: InternalsVisibleTo("BepInEx.IL2CPP")]
@@ -1,6 +1,6 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("BepInEx.Preloader.Unity")]
[assembly: InternalsVisibleTo("BepInEx.Preloader.UnityMono")]
[assembly: InternalsVisibleTo("BepInEx.NetLauncher")]
[assembly: InternalsVisibleTo("BepInEx.NetCore")]
[assembly: InternalsVisibleTo("BepInEx.IL2CPP")]
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net35;netstandard2.0</TargetFrameworks>
<AssemblyTitle>BepInEx.Preloader.Unity</AssemblyTitle>
<Product>BepInEx.Preloader.Unity</Product>
<AssemblyTitle>BepInEx.Preloader.UnityMono</AssemblyTitle>
<Product>BepInEx.Preloader.UnityMono</Product>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<RootNamespace>BepInEx.Preloader.UnityMono</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net35'">
<!-- Output only net35 version to distribution; netstadnard is only used for generating NuGet package -->
<OutputPath>..\bin\Unity\</OutputPath>
<OutputPath>..\bin\UnityMono\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
@@ -1,8 +1,9 @@
using System;
using System.IO;
using BepInEx.Preloader.Core;
using BepInEx.Preloader.Unity;
using BepInEx.Preloader.UnityMono;
// ReSharper disable once CheckNamespace
namespace Doorstop;
internal static class Entrypoint
@@ -24,9 +25,9 @@ internal static class Entrypoint
// In some versions of Unity 4, Mono tries to resolve BepInEx.dll prematurely because of the call to Paths.SetExecutablePath
// To prevent that, we have to use reflection and a separate startup class so that we can install required assembly resolvers before the main code
typeof(Doorstop.Entrypoint).Assembly.GetType($"BepInEx.Preloader.Unity.{nameof(UnityPreloaderRunner)}")
?.GetMethod(nameof(UnityPreloaderRunner.PreloaderPreMain))
?.Invoke(null, null);
typeof(Entrypoint).Assembly.GetType($"BepInEx.Preloader.UnityMono.{nameof(UnityPreloaderRunner)}")
?.GetMethod(nameof(UnityPreloaderRunner.PreloaderPreMain))
?.Invoke(null, null);
}
catch (Exception ex)
{
@@ -9,7 +9,7 @@ using BepInEx.Preloader.Core.Patching;
using Mono.Cecil;
using Mono.Cecil.Cil;
namespace BepInEx.Preloader.Unity;
namespace BepInEx.Preloader.UnityMono;
[PatcherPluginInfo("io.bepinex.entrypointpatcher", "BepInEx Entrypoint", "1.0")]
internal class EntrypointPatcher : BasePatcher
@@ -56,7 +56,7 @@ internal class EntrypointPatcher : BasePatcher
if (entryType == null)
throw new Exception("The entrypoint type is invalid! Please check your config/BepInEx.cfg file");
var chainloaderAssemblyPath = Path.Combine(Paths.BepInExAssemblyDirectory, "BepInEx.Unity.dll");
var chainloaderAssemblyPath = Path.Combine(Paths.BepInExAssemblyDirectory, "BepInEx.UnityMono.dll");
var readerParameters = new ReaderParameters
{
@@ -4,7 +4,7 @@ using System.Linq;
using System.Reflection;
using HarmonyLib;
namespace BepInEx.Preloader.RuntimeFixes;
namespace BepInEx.Preloader.UnityMono.RuntimeFixes;
/// <summary>
/// This exists because the Mono implementation of <see cref="Trace" /> is/was broken, and would call Write directly
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Reflection;
using HarmonyLib;
namespace BepInEx.Preloader.RuntimeFixes;
namespace BepInEx.Preloader.UnityMono.RuntimeFixes;
internal static class UnityPatches
{
@@ -7,7 +7,7 @@ using MonoMod.RuntimeDetour;
using MonoMod.RuntimeDetour.Platforms;
using MonoMod.Utils;
namespace BepInEx.Preloader.RuntimeFixes;
namespace BepInEx.Preloader.UnityMono.RuntimeFixes;
internal static class XTermFix
{
@@ -9,9 +9,10 @@ using BepInEx.Preloader.Core;
using BepInEx.Preloader.Core.Logging;
using BepInEx.Preloader.Core.Patching;
using BepInEx.Preloader.RuntimeFixes;
using BepInEx.Preloader.UnityMono.RuntimeFixes;
using MonoMod.Utils;
namespace BepInEx.Preloader.Unity;
namespace BepInEx.Preloader.UnityMono;
/// <summary>
/// The main entrypoint of BepInEx, and initializes all patchers and the chainloader.
@@ -4,8 +4,9 @@ using System.Linq;
using System.Reflection;
using BepInEx.Preloader.Core;
using BepInEx.Preloader.RuntimeFixes;
using BepInEx.Preloader.UnityMono.RuntimeFixes;
namespace BepInEx.Preloader.Unity;
namespace BepInEx.Preloader.UnityMono;
internal static class UnityPreloaderRunner
{
@@ -3,7 +3,7 @@ using BepInEx.Configuration;
using BepInEx.Logging;
using UnityEngine;
namespace BepInEx;
namespace BepInEx.UnityMono;
/// <summary>
/// The base plugin type that is used by the BepInEx plugin loader.
@@ -30,7 +30,7 @@ public abstract class BaseUnityPlugin : MonoBehaviour
Location = GetType().Assembly.Location
};
Logger = Logging.Logger.CreateLogSource(metadata.Name);
Logger = BepInEx.Logging.Logger.CreateLogSource(metadata.Name);
Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false, metadata);
}
@@ -2,19 +2,20 @@
<PropertyGroup>
<Description>BepInEx support library for Mono Unity games</Description>
<TargetFrameworks>net35;netstandard2.0</TargetFrameworks>
<AssemblyTitle>BepInEx.Unity</AssemblyTitle>
<Product>BepInEx.Unity</Product>
<AssemblyTitle>BepInEx.UnityMono</AssemblyTitle>
<Product>BepInEx.UnityMono</Product>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<RootNamespace>BepInEx.UnityMono</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net35'">
<!-- Output only net35 version to distribution; netstandard is only used for generating NuGet package -->
<OutputPath>..\bin\Unity\</OutputPath>
<!-- Output only net35 version to distribution; netstadnard is only used for generating NuGet package -->
<OutputPath>..\bin\UnityMono\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BepInEx.Core\BepInEx.Core.csproj"/>
<ProjectReference Include="..\BepInEx.Preloader.Core\BepInEx.Preloader.Core.csproj" PrivateAssets="All"/>
<ProjectReference Include="..\BepInEx.Preloader.Unity\BepInEx.Preloader.Unity.csproj" PrivateAssets="All"/>
<ProjectReference Include="..\BepInEx.Preloader.UnityMono\BepInEx.Preloader.UnityMono.csproj" PrivateAssets="All"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All"/>
@@ -1,6 +1,6 @@
using BepInEx.Unity.Bootstrap;
using BepInEx.UnityMono.Bootstrap;
namespace BepInEx.Unity;
namespace BepInEx.UnityMono;
public static class BepInExInstance
{
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@@ -7,7 +7,7 @@ using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Preloader.Core.Logging;
using BepInEx.Unity.Logging;
using BepInEx.UnityMono.Logging;
using MonoMod.Utils;
using UnityEngine;
using Logger = BepInEx.Logging.Logger;
@@ -16,7 +16,7 @@ using Object = UnityEngine.Object;
[assembly: InternalsVisibleTo("UnityEngine")]
[assembly: InternalsVisibleTo("UnityEngine.Core")]
namespace BepInEx.Unity.Bootstrap;
namespace BepInEx.UnityMono.Bootstrap;
/// <summary>
/// The manager and loader for all plugins, and the entry point for BepInEx plugin system.
@@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BepInEx.Configuration;
using BepInEx.Logging;
using UnityEngine;
using Logger = BepInEx.Logging.Logger;
namespace BepInEx.Configuration;
namespace BepInEx.UnityMono.Configuration;
/// <summary>
/// A keyboard shortcut that can be used in Update method to check if user presses a key combo. The shortcut is only
@@ -54,7 +55,7 @@ public struct KeyboardShortcut
/// <param name="mainKey">Main key to press</param>
/// <param name="modifiers">Keys that should be held down before main key is registered</param>
public KeyboardShortcut(KeyCode mainKey, params KeyCode[] modifiers) : this(new[] { mainKey }.Concat(modifiers)
.ToArray())
.ToArray())
{
if (mainKey == KeyCode.None && modifiers.Any())
throw new
@@ -7,7 +7,7 @@ using BepInEx.Logging;
using UnityEngine;
using Logger = BepInEx.Logging.Logger;
namespace BepInEx.Unity.Logging
namespace BepInEx.UnityMono.Logging
{
/// <summary>
/// Logs entries using Unity specific outputs.
@@ -3,7 +3,7 @@ using System.Reflection;
using BepInEx.Logging;
using UnityEngine;
namespace BepInEx.Unity.Logging;
namespace BepInEx.UnityMono.Logging;
/// <summary>
/// Logs entries using Unity specific outputs.
@@ -8,7 +8,7 @@ using BepInEx.Logging;
using UnityEngine;
using Logger = BepInEx.Logging.Logger;
namespace BepInEx;
namespace BepInEx.UnityMono;
/// <summary>
/// Provides methods for running code on other threads and synchronizing with the main thread.
@@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
using BepInEx.Configuration;
using UnityEngine;
namespace BepInEx.Unity;
namespace BepInEx.UnityMono;
/// <summary>
/// Config types that are unity specific
+3 -3
View File
@@ -10,13 +10,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BepInExTests", "BepInExTest
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BepInEx.Preloader.Core", "BepInEx.Preloader.Core\BepInEx.Preloader.Core.csproj", "{15F8BC38-A761-4F93-8903-1B531AC5D9F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BepInEx.Unity", "BepInEx.Unity\BepInEx.Unity.csproj", "{EAE9FAE6-8011-45A3-8B6E-0C7F14210533}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BepInEx.UnityMono", "BepInEx.UnityMono\BepInEx.UnityMono.csproj", "{EAE9FAE6-8011-45A3-8B6E-0C7F14210533}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BepInEx.Preloader.Unity", "BepInEx.Preloader.Unity\BepInEx.Preloader.Unity.csproj", "{D404C973-441D-48ED-B266-C21320BA0D87}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BepInEx.Preloader.UnityMono", "BepInEx.Preloader.UnityMono\BepInEx.Preloader.UnityMono.csproj", "{D404C973-441D-48ED-B266-C21320BA0D87}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BepInEx.Core", "BepInEx.Core\BepInEx.Core.csproj", "{4FFBA620-F5ED-47F9-B90C-DAD1316FD9B9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Unity", "Unity", "{6E2DD21E-0854-4F4A-B925-D90E0016D03D}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnityMono", "UnityMono", "{6E2DD21E-0854-4F4A-B925-D90E0016D03D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BepInEx.NetLauncher", "BepInEx.NetLauncher\BepInEx.NetLauncher.csproj", "{490B052B-7F23-4052-AD04-613856618901}"
EndProject
+1 -1
View File
@@ -32,6 +32,6 @@
<ProjectReference Include="..\BepInEx.Core\BepInEx.Core.csproj"/>
<ProjectReference Include="..\BepInEx.IL2CPP\BepInEx.IL2CPP.csproj"/>
<!-- BepInEx.Unity only targets net35 because that's supported by all mono variants. -->
<ProjectReference Include="..\BepInEx.Unity\BepInEx.Unity.csproj"/>
<ProjectReference Include="..\BepInEx.UnityMono\BepInEx.UnityMono.csproj"/>
</ItemGroup>
</Project>
+1 -1
View File
@@ -266,7 +266,7 @@ Task("MakeDist")
foreach (Target target in targets) {
(ConvertableDirectoryPath originDir, ConvertableFilePath? doorstopConfigFile) = (Directory(target.Abi), null);
if (target.Abi is var abi and ("UnityIL2CPP" or "UnityMono")) {
originDir = Directory(abi is "UnityIL2CPP" ? "IL2CPP" : "Unity");
originDir = Directory(abi is "UnityIL2CPP" ? "IL2CPP" : "UnityMono");
// TODO: Move config file resolving to Target class
doorstopConfigFile = File(
target.IsUnix ?
+1 -1
View File
@@ -6,7 +6,7 @@ enabled=true
# Path to the assembly to load and execute
# NOTE: The entrypoint must be of format `static void Doorstop.Entrypoint.Start()`
target_assembly=BepInEx\core\BepInEx.Preloader.Unity.dll
target_assembly=BepInEx\core\BepInEx.Preloader.UnityMono.dll
# If true, Unity's output log is redirected to <current folder>\output_log.txt
redirect_output_log=false