BepInEX框架
BepInEX项目配置
BepInEX使用外部资源
在Editor内使用unity官方的Assetbundle Browser生成ab包,LoadFromFile导入游戏即可
可用Paths类获取插件所在路径
也可以在项目配置里内嵌入dll:
BepInEX与Unity Editor协作
可以直接在Editor的项目里写空类(只包含变量和方法的定义)
要使用原版游戏的MonoBehaviour,在编辑器新建同名类即可
使用bepinex插件内的MonoBehaviour,将插件dll添加到unity中并在inspector关闭自动引用和可用性检测即可
或者反编译之后改extren代码
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 33 34 35
| var harmony = new Harmony("patch");
Class {}
[HarmonyPatch(typeof(Class), "MethodName")] class Class_Patch { public static bool Prefix () {} public static void Postfix () {} }
class Class_Patch2 { [HarmonyPatch(typeof(Class), "MethodName")] [HarmonyPrefix] public static bool Method () {}
}
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 13 14 15 16 17
| DontDestoryObject( gameObject );
public static class Class{}
Task.Run( () => { }); Task.Run( Method );
|