BepInEX框架
BepInEX项目配置
BepInEX使用外部资源
在Editor内使用unity官方的Assetbundle Browser生成ab包,loadfromfile导入游戏即可
可用Paths类获取插件所在路径
BepInEX与Unity Editor协作
在Editor内使用bepinex插件内的MonoBehaviour
直接在Editor里写空操作(只包含变量和方法的定义)MonoBehaviour组件在实际载入游戏时只有原版游戏的MonoBehaviour会被target,插件的则会因为找不到而不挂载
将插件dll添加到unity中并在inspector关闭自动引用和可用性检测即可
或者extren代码
对于游戏原版的Assembly-CSharp,同,可用dsSpy修改dll名
HarmonyX
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| var harmony = new Harmony("patch");
Class {}
[HarmonyPatch] class Class_Patch {}
class Class_Patch2 { [HarmonyPatch()] [HarmonyPatch()] [HarmonyPrefix] public static bool Methob () {}
}
harmony.PatchAll();
harmony.PatchAll( Assembly.GetAssembly( typeof(Class_Patch) ) );
CreateAndPatchAll( typeof(Class_Patch) );
harmony.Unpatch( typeof(Class).GetMethob("methob"), HarmonyPatch.Perfix );
harmony.UnpatchSelf();
|
BepInEX
Unity
1 2 3 4 5 6 7 8 9 10 11 12
| DontDestoryObject( gameObject );
public static class Class{}
Task.Run( () => { });
|