Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
7b81646
fix https://github.com/Tencent/InjectFix/issues/22
chexiongsheng Oct 9, 2019
b0382aa
patch一个带泛型参数的函数时,友好的提示不支持
chexiongsheng Oct 9, 2019
11851f6
注入阶段,如果处理指令时异常,只打印warning,因为可以在修复阶段规避
chexiongsheng Oct 10, 2019
1cd8b22
删除编译的dll和exe,强制必现自行编译才能用
chexiongsheng Oct 10, 2019
4dff7cc
定位travis-ci升级mono版本后有个用例不过,打印ci环境下其生成的指令
chexiongsheng Oct 10, 2019
090ccf5
1、回退ci定位的指令打印;
chexiongsheng Oct 10, 2019
5a12085
ci失败的原因:travis更新mono后对"ValueTypeCounter { " + i + " }"产生的指令是调用i的tostr…
chexiongsheng Oct 10, 2019
d818d9d
unix lf
chexiongsheng Oct 10, 2019
b10ecc1
把IFix.Core.dll的meta文件提交,防止下载代码后Assets/Plugins目录为空
chexiongsheng Oct 11, 2019
3861a2c
修改文本编码,避免在其他平台显示乱码问题 (#28)
yangruihan Oct 11, 2019
f46ff5e
【优化IFix报错日志】使用debug模式运行ifix.exe,报错日志里包含源码文件和行信息,方便查问题。 (#31)
treert Oct 12, 2019
691c4d1
注入和生成patch加入进度条 fix https://github.com/Tencent/InjectFix/issues/32
chexiongsheng Oct 15, 2019
fac9ce6
Merge branch 'master' of https://github.com/Tencent/InjectFi
chexiongsheng Oct 15, 2019
5ac9693
闭包中调用一个泛型,在unity2018的.net 3.5设置下,编译器是先生成一个泛型的闭包实现,然后实例化,很奇怪的做法,老版本uni…
chexiongsheng Dec 2, 2019
1f73995
当值类型无override方法时,一些编译器仍然生成Constrained,这种情况下之前的处理在函数含参数时处理不当,fix https…
chexiongsheng Dec 12, 2019
6c2716b
解决unbox一个枚举变量时报错的问题
chexiongsheng Jan 13, 2020
363481e
in关键字修饰参数的支持:1、in修饰的参数不用从虚拟机栈设置回去;2、如果是虚方法,参数会被包裹在RequiredModifierTyp…
chexiongsheng Jan 14, 2020
3ed5373
换行符统一
chexiongsheng Jan 20, 2020
4f00ce8
结构体局部变量添加初始化指令,fix https://github.com/Tencent/InjectFix/issues/74
chexiongsheng Jan 21, 2020
6e1bcfc
刚刚的提交没去掉日志打印
chexiongsheng Jan 21, 2020
2a29e25
有些严格些的编译器会报未初始化访问,fix https://github.com/Tencent/InjectFix/issues/67
chexiongsheng Jan 21, 2020
4ab7bbe
解决带in参数且override父类的函数在制作补丁时被忽略的问题,fix https://github.com/Tencent/Inje…
chexiongsheng Jan 21, 2020
fa7c9a2
support method filter for inject stage
chexiongsheng Feb 19, 2020
ac6abf5
规避il2cpp在字段个数大于32767生成代码报错的bug
chexiongsheng Mar 17, 2020
07c5294
在这个修改https://github.com/Tencent/InjectFix/commit/4f00ce8eb1c1e238b6c7…
chexiongsheng Mar 20, 2020
4868017
注入步骤不验证内部方法id是否超过ushort.MaxValue
chexiongsheng Mar 23, 2020
c5a938d
[Change] (#68)
JourneyHans Apr 21, 2020
5c540ec
add Interpret class (#107)
annayxguo Apr 24, 2020
0a7da39
添加新增类的演示例子
chexiongsheng Apr 25, 2020
783cae8
统一换行符
chexiongsheng Apr 25, 2020
b0e4e8f
匿名类,新类对象字段未初始化读,会导致定位到错误的对象的问题, fix https://github.com/Tencent/Inject…
chexiongsheng Apr 26, 2020
35973e7
[fixbug] CustomBridge 注入跨dll的delegate,InjectFix 时报错。 (#108)
treert Apr 27, 2020
c957057
低版本Unity 没有ISubsystem 添加,并且把NewClassTest添加到注入列表 (#113)
annayxguo Apr 27, 2020
a7ca09d
格式整理
chexiongsheng Apr 27, 2020
6085a01
验证新增类的类名是否存在 (#114)
annayxguo Apr 29, 2020
fc06552
修改代码小细节 (#115)
annayxguo Apr 30, 2020
55624c9
反射调用原生 参数[in][out]问题 fix https://github.com/Tencent/InjectFix/issues/…
annayxguo May 8, 2020
57482b9
如果是TargetInvocationException,throw它的innerException
chexiongsheng May 8, 2020
55f3470
先去掉新增类的标签,否则Helloworld例子加载补丁失败 fix https://github.com/Tencent/InjectF…
chexiongsheng May 11, 2020
3fab5d0
实现新增类可以继承新增类的功能 (#130)
annayxguo May 28, 2020
c6f23a5
支持继承时重写object的虚函数 (#136)
annayxguo Jun 4, 2020
64e680b
解决 赋值给delegate的是一个新类的虚函数 (#140)
annayxguo Jun 5, 2020
0abc9c5
解决 Unity版本不兼容 而出现的Ldelem_Any指令的问题 #fix https://github.com/Tencent/Inj…
annayxguo Jun 5, 2020
f52a4f9
这个commit,https://github.com/Tencent/InjectFix/commit/5a1208532681b7bc…
chexiongsheng Jun 18, 2020
0096a6a
fix https://github.com/Tencent/InjectFix/issues/156
chexiongsheng Jun 26, 2020
e94f9f2
解决新增类实现的接口中有event问题 fix https://github.com/Tencent/InjectFix/issues/1…
annayxguo Jun 28, 2020
1f4d045
支持async特性 fix https://github.com/Tencent/InjectFix/issues/124 (#160)
annayxguo Jul 1, 2020
85a3f71
高版本unity没有gmsc,只有msc,做下兼容
chexiongsheng Jul 6, 2020
71bf228
Merge branch 'master' of https://github.com/Tencent/InjectFix
chexiongsheng Jul 6, 2020
081b67f
解决 新类子类重写父类函数时base关键字后还有语句并未走到的问题 fix https://github.com/Tencent/Inje…
annayxguo Jul 13, 2020
53ccd7d
解决 双击IFix.exe报错问题 fix https://github.com/Tencent/InjectFix/issues/167…
annayxguo Jul 14, 2020
bc4f2b3
解决 方法参数中的struct被当作引用类型处理 fix https://github.com/Tencent/InjectFix/iss…
annayxguo Jul 24, 2020
b0e60e4
解决 out struct类型在Inject时报错 fix https://github.com/Tencent/InjectFix/is…
annayxguo Jul 31, 2020
7a6e6d3
修改CecilExtensions.cs下的TryImport函数的判空条件位置 fix https://github.com/Tence…
annayxguo Jul 31, 2020
31e1bd9
InjectFix使用手册 (#189)
annayxguo Aug 3, 2020
2f36c1f
修改使用手册 (#191)
annayxguo Aug 4, 2020
35cb0ab
加上手册的链接
chexiongsheng Aug 4, 2020
aa2fb09
添加英文版使用手册 (#193)
annayxguo Aug 5, 2020
3e1b240
更新文档链接
chexiongsheng Aug 5, 2020
c8bccd0
修复uint转换ulong时结果不正确的问题,fix https://github.com/Tencent/InjectFix/issue…
chexiongsheng Aug 10, 2020
6756f1d
修改使用手册 fix https://github.com/Tencent/InjectFix/issues/202 (#204)
annayxguo Aug 12, 2020
7a77897
fix https://github.com/Tencent/InjectFix/issues/199
chexiongsheng Aug 25, 2020
39706a9
去掉无用变量
chexiongsheng Aug 31, 2020
9873ef5
增加是否检查新类已经存在的选项
chexiongsheng Aug 31, 2020
aa6289c
解决新增协程 添加IEnumerator<System.Object>到CustomBridge报错问题 fix https://gith…
annayxguo Sep 4, 2020
e8821e1
增加说明CustomBridge不能放到Editor目录的说明
chexiongsheng Sep 12, 2020
743a2d9
优化说明
chexiongsheng Sep 12, 2020
086bfa1
格式优化
chexiongsheng Sep 12, 2020
794a047
解决ios的async/await报错 fix https://github.com/Tencent/InjectFix/issues/2…
annayxguo Sep 15, 2020
78a2947
解决补丁函数里通过base调用父类函数报错问题 (#231)
annayxguo Sep 22, 2020
8118412
fix https://github.com/Tencent/InjectFix/issues/236
chexiongsheng Sep 29, 2020
c1dbe4b
优化文档
chexiongsheng Oct 28, 2020
71b63bd
注入时过滤掉返回类型是ref readonly fix https://github.com/Tencent/InjectFix/issu…
annayxguo Oct 29, 2020
8bf73a7
丰富报错信息
chexiongsheng Nov 10, 2020
59034c7
Merge branch 'master' of https://github.com/Tencent/InjectFix
chexiongsheng Nov 10, 2020
3084863
未配置CustomBridge有更友好的提示
chexiongsheng Nov 17, 2020
eec6828
nullable本身是值类型,但如果没有值时boxing后会为null,在clone时应该特殊处理,fix https://github.…
chexiongsheng Nov 17, 2020
f833bdb
换行符转换
chexiongsheng Dec 4, 2020
59b0948
base调用不一定会本类父类方法调用,比如迭代器语法糖里头,在迭代器的base调用,会出现在编译器生成类里头,fix https://gi…
chexiongsheng Dec 4, 2020
1d0db7a
多个子类,只对虚方法生成一个proxy的话,后续补丁时不知道之前生成的是那个类的proxy,可能会调用失败。
chexiongsheng Dec 7, 2020
ca5ca33
上个提交的日志忘了去掉
chexiongsheng Dec 7, 2020
b29ac8a
fix https://github.com/Tencent/InjectFix/issues/275
chexiongsheng Jan 20, 2021
9f19181
fixed build_for_unity.sh for MacOS (#266)
sandin Feb 4, 2021
4c7b70e
新增字段支持,以及新增类型的类型转换支持 (#277)
mercurylu Feb 5, 2021
5ce05ca
Fix #282 (#283)
mercurylu Feb 26, 2021
9ace2f2
Fix #286 (#287)
mercurylu Mar 2, 2021
08ad61f
Update faq.md
chexiongsheng Mar 3, 2021
1ef6a9c
Fix #289 (#290)
mercurylu Mar 10, 2021
b912615
update user manual (#292)
mercurylu Mar 11, 2021
af8cf9f
修复async函数不能热更的问题 (#298)
lafirest Mar 18, 2021
1b02996
get/set函数只有一个情况下处理会报错 (#295)
mercurylu Mar 18, 2021
ecd77d8
编译错误
chexiongsheng Mar 19, 2021
c29b1d2
去掉不支持的用法
chexiongsheng Mar 24, 2021
25f0f0f
更新使用手册
chexiongsheng Mar 26, 2021
8d3768e
解决对空对象as报错的问题,fix https://github.com/Tencent/InjectFix/issues/311
chexiongsheng Apr 30, 2021
c55a06f
修复新增字段初始化过程中类型不正确的问题 (#319)
mercurylu Jun 2, 2021
c1e1c68
增加生成补丁时对调用"返回ref类型的方法"情况的警告
xuyanghuang-tencent Jul 29, 2021
131dcc2
获取builder如果出现异常,只打印,不中断注入,fix https://github.com/Tencent/InjectFix/is…
chexiongsheng Sep 22, 2021
259b888
Inject后显示调用Unity加载注入后的dll代码 (#340)
PresleyInGitHub Oct 11, 2021
e3be7e9
EditorUtility.RequestScriptReload()是2019.3.0之后新增的API (#341)
PresleyInGitHub Oct 13, 2021
b1676f1
fix: Callvirt被错误的生成为Callvirtvirt
Dec 10, 2021
c209cfa
Merge pull request #350 from mercurylu/master
xuyanghuang-tencent Dec 10, 2021
9d8e950
新增对泛型字段访问支持
xuyanghuang-tencent Jan 17, 2022
cb500cc
泛型报错时输出更多log信息 (#360)
shaoyy Feb 8, 2022
4267aff
checkNew可以控制不检查新增字段;友善提示空实例反射异常。 (#346)
HuangXiaowen1989 Feb 8, 2022
552da36
fix: that cannot be built under linux unity (#365)
ymh199478 Apr 19, 2022
5ba42eb
更新LICENSE的公司主体
xuyanghuang-tencent Jul 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Doc/faq.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
## ִ��Patch for android����Patch for iosʱ������"please put template file for android/ios in IFixToolKit directory!��
## 执行Patch for android或者Patch for ios时,报“"please put template file for android/ios in IFixToolKit directory!

������������Ҫ����һ������ģ���ļ��ŵ�IFixToolKitĿ¼��
解决这个错误需要制作一个编译模版文件放到IFixToolKit目录:

* ��������������android��ģ�棬��ִ��һ����ͨ��android�������ڹ����Ĺ����У���������Ŀ¼/Temp��Ŀ¼��UnityTempFile��ͷ���ļ�����������������һ����UnityTempFile��ͷ�����ļ�������ոմ���������ļ������Ը����ļ�ʱ������ļ���ͷ�������в�����ios������ôһ�У�-define:UNITY_IOS��android����-define:UNITY_ANDROID�����ұ���û��UNITY_EDITOR���ҵ�����������IFixToolKitĿ¼���������window��ȡ��UnityTempFile��������Ϊandroid.win.tpl�������mac�»�ȡ�ģ�������Ϊandroid.osx.tpl�����ⲽ����һ����Ŀ������㲻����unity�汾����������������꣬������һ�μ��ɣ�
* ios��ģ���ļ�����Ϊios.osx.tpl�������ϣ����window������ios����������һ�ݸ���Ϊios.win.tpl��������ļ��������ӵ�����dll��ϵͳ��dll��·����window��unity��װĿ¼�޸ġ�
* 假如你制作的是android的模版,请执行一次普通的android构建,在构建的过程中,到“工程目录/Temp”目录把UnityTempFile打头的文件都拷贝出来,其中一个“UnityTempFile开头”的文件就是你刚刚打包命令行文件,可以根据文件时间或者文件里头的命令行参数(ios会有这么一行:-define:UNITY_IOS,android会有-define:UNITY_ANDROID,而且必须没有UNITY_EDITOR)找到它,拷贝到IFixToolKit目录,如果你在window获取的UnityTempFile,重命名为android.win.tpl,如果是mac下获取的,重命名为android.osx.tpl;(这步对于一个项目,如果你不升级unity版本,不更改条件编译宏,仅需做一次即可)
* ios的模版文件改名为ios.osx.tpl,如果你希望在window下制作ios补丁,复制一份改名为ios.win.tpl,打开这个文件,把链接的引擎dll,系统级dll的路径按window的unity安装目录修改。

## IL2CPP ���ֱ���`IL2CPP error for method 'System.Object IFix.Core.EvaluationStackOperation::ToObject(IFix.Core.Value*,IFix.Core.Value*,System.Object[],System.Type,IFix.Core.VirtualMachine,System.Boolean)'`
## IL2CPP 出现报错`IL2CPP error for method 'System.Object IFix.Core.EvaluationStackOperation::ToObject(IFix.Core.Value*,IFix.Core.Value*,System.Object[],System.Type,IFix.Core.VirtualMachine,System.Boolean)'`

Ӧ�����Լ��ֶ�����`IFix.Core.dll`����
应该是自己手动编译`IFix.Core.dll`导致

�޸�iFix.CoreԴ�������Ҫͨ��`build_for_unity.bat`�ű����й���
修改iFix.Core源代码后,需要通过`build_for_unity.bat`脚本进行构建

## ���� Patch ��ʱ������`Error: the new assembly must not be inject, please reimport the project!`����
## 生成 Patch 的时候遇到`Error: the new assembly must not be inject, please reimport the project!`报错

���� Patch �� dll�����ܽ���ע��
这个dll执行过注入,不能对注入过的dll生成patch,在Unit选工程根目录,右键选reimport

## �����������������������
## 补丁制作的条件编译宏如何处理

�����Unity2018.3�汾�����ϣ�����Unity������C#����ӿڣ�����InjectFix��Unity2018.3�汾ֱ��֧��Android��iOS�IJ������ɣ�ֱ��ִ�ж�Ӧ�˵����ɡ�
如果是Unity2018.3版本及以上,由于Unity开放了C#编译接口,所以InjectFix在Unity2018.3版本直接支持Android和iOS的补丁生成,直接执行对应菜单即可。

���������Unity2018.3�汾����Ҫ�ñȽ��鷳�ķ�ʽ������Ӧƽ̨�ı��������Assembly-CSharp.dll���������Ȼ�����IFix.Editor.IFixEditor.GenPatchȥ���ɲ�����
但如果低于Unity2018.3版本,则要用比较麻烦的方式:按对应平台的编译参数把Assembly-CSharp.dll编译出来,然后调用IFix.Editor.IFixEditor.GenPatch去生成补丁。

Unity�������ڹ��̵�TempĿ¼�½�һ���ļ����������в����ŵ��Ǹ��ļ���Ȼ��ִ�����ƣ�Ŀ¼�����Լ���unity��װ�������������������б��룺
Unity编译是在工程的Temp目录新建一个文件,把命令行参数放到那个文件,然后执行类似(目录根据自己的unity安装情况而定)如下命令进行编译:

~~~bash
"D:\Program Files\Unity201702\Editor\Data\MonoBleedingEdge\bin\mono.exe" "D:\Program Files\Unity201702\Editor\Data\MonoBleedingEdge\lib\mono\4.5\mcs.exe" @Temp/UnityTempFile-55a959adddae39f4aaa18507dd165989
~~~

����Գ���һ�α༭���µ��ֻ��汾�����Ȼ�󵽹���Ŀ¼�µ�TempĿ¼���Ǹ���ʱ�ļ�������������������Զ�ɾ��������Ҫ�ֿ죩��
你可以尝试一次编辑器下的手机版本打包,然后到工程目录下的Temp目录把那个临时文件拷贝出来(编译完会自动删掉,所以要手快)。

����ļ�������ط��������ģ������Ҫ��C#�ļ��б������Ը�Ϊ��̬��������ļ���C#�ļ��б����ݵ�ǰ��Ŀ���ɣ��������ֲ��䡣Ȼ��������ļ���Ϊ���������롣
这个文件大多数地方都不会变的,变的主要是C#文件列表,可以改为动态生成这个文件:C#文件列表根据当前项目生成,其它保持不变。然后用这个文件作为输入来编译。
2 changes: 1 addition & 1 deletion Doc/quick_start_en.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Quick Start
## Quick Start

### Access example

Expand Down
331 changes: 331 additions & 0 deletions Doc/user_manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
# IFix使用手册

### [IFix.Patch]

##### 用途

​ 在补丁阶段使用;原生代码修复。如果发现某个函数有错误,就可以使用该标签给函数打补丁,打上这个标签的函数,童鞋们就可以随意修改该函数。

##### 用法

​ 该标签只能用在方法上,直接在要修改的函数上面标注一下这个标签即可。

##### 举例

​ 这个函数本来的意思是两个值相加,但现在写错了,所以可以给该函数打上[IFix.Patch]标签,然后修改就可以了

```c#
public int Add(int a,int b)
{
return a*b;
}
```

```c#
[IFix.Patch]
public int Add(int a,int b)
{
return a+b;
}
```

### [IFix.Interpret]

##### 用途

​ 在补丁阶段使用;新增代码。在补丁阶段,童鞋们还有新的需求,想新增个字段,函数或者类,可以用[IFix.Interpret]标签实现。

##### 用法

​ 该标签可以用在字段,属性,方法,类型上,直接在要新增的代码上面标注一下这个标签即可。

##### 举例

​ 新增一个字段

```c#
public class Test
{
[IFix.Interpret]
public int intValue = 0;
}
```

​ 新增一个属性

```c#
private string name;//这个name字段是原生的

public string Name
{
[IFix.Interpret]
set
{
name = value;
}
[IFix.Interpret]
get
{
return name;
}
}

[IFix.Interpret]
public string Id
{
set;
get;
}

```

​ 新增一个函数

```c#
[IFix.Interpret]
public int Sub(int a,int b)
{
return a-b;
}
```

​ 新增一个类

```c#
[IFix.Interpret]
public class NewClass
{
...
}
```

### [IFix.CustomBridge]

##### 用途

​ 在注入阶段使用; 把一个虚拟机的类适配到原生interface或者把一个虚拟机的函数适配到原生delegate。

​ 什么时候需要用到呢?

- 修复代码赋值一个闭包到一个delegate变量;
- 修复代码的Unity协程用了yield return;
- 新增一个函数,赋值到一个delegate变量;
- 新增一个类,赋值到一个原生interface变量;
- 新增函数,用了yield return;

##### 用法

​ 该标签只能用在类上,在童鞋们程序的某个地方,写上一个静态类,里面有一个静态字段,值就是interface和delegate的类型集合

!!注意,该配置类不能放到Editor目录,且不能内嵌到另外一个类里头。

##### 举例

​ 新增一个类,该类实现了一个接口

```c#
public interface ISubSystem
{
bool running { get; }
void Print();
}

[IFix.Interpret]
public class SubSystem : ISubSystem
{
public bool running { get { return true; } }
public void Print()
{
UnityEngine.Debug.Log("SubSystem1.Print");
}
}
```

​ 新增函数(或者修复代码[IFix.Patch]的Unity协程),用到了 yield return

```c#
[IFix.Interpret]
public IEnumerator TestInterface()
{
yield return new WaitForSeconds(1);
UnityEngine.Debug.Log("wait one second");
}
```

​ 新增函数(或者修复代码[IFix.Patch]),赋值到一个delegate变量

```c#
public class Test
{
public delegate int MyDelegate(int a, int b);

[IFix.Interpret]
public MyDelegate TestDelegate()
{
return (a,b) => a + b;
}
}
```

```c#
[IFix.CustomBridge]
public static class AdditionalBridge
{
static List<Type> bridge = new List<Type>()
{
typeof(ISubSystem),
typeof(IEnumerator),
typeof(Test.MyDelegate)
};
}
```



### [Configure]

##### 用途

​ 在注入阶段使用;配置类,里面存储的是一些注入时需要注入或过滤的东西。

##### 用法

​ 该标签只能用在类上,该类必须在Editor文件夹下 。

##### 举例

```c#
[Configure]
public class TestCfg
{

}
```

### [IFix]

##### 用途

​ 在注入阶段使用;用来存储所有你认为将来可能会需要修复的类的集合。该标签和[IFix.Patch]有关联,因为如果发现某个函数需要修复,直接打上[IFix.Patch]标签就可以了,但是前提是,这个需要修复的函数的类必须在[IFix]下。

##### 用法

​ 该标签只能用在属性上,Configure类中的一个静态属性,get得到的是可能会需要修复的函数所有类的集合

##### 举例

​ 认为Test类里面的函数可能会出错,所以把它们放到[IFix]标签下,当Test类中的Add函数需要修复,直接打标签修改即可。

```c#
[Configure]
public class TestCfg
{
[IFix]
static IEnumerable<Type> hotfix
{
get
{
return new List<Type>()
{
typeof(Test)
};
}
}
}

public class Test
{
[IFix.Patch]
public int Add(int a,int b)
{
return a+b;
}
}
```

### [Filter]

##### 用途

​ 在注入阶段使用;用来存储想要过滤的东西。在注入阶段,凡是在[IFix]标签下的属性里面的值,都会被注入适配代码,但是如果不想对某个函数进行注入,可以用该标签进行过滤。

##### 用法

​ 该标签只能用在方法上,Configure类中的一个静态方法。

##### 举例

​ 觉得Test类里的函数可能会需要修复,但是Test类里面的Div和Mult不可能有问题,可以把这两个函数过滤掉。

```c#
public class Test
{
[IFix.Patch]
public int Add(int a,int b)
{
return a+b;
}
public int Sub(int a,int b)
{
return a-b;
}
public int Div(int a,int b)
{
return a/b;
}
public int Mult(int a,int b)
{
return a*b;
}
}

[Configure]
public class TestCfg
{
[IFix]
static IEnumerable<Type> hotfix
{
get
{
return new List<Type>()
{
typeof(Test)
};
}
}
[Filter]
static bool Filter(System.Reflection.MethodInfo methodInfo)
{
return methodInfo.DeclaringType.FullName == "Test"
&& (methodInfo.Name == "Div" || methodInfo.Name == "Mult");
}
}

```



### 注意事项

- 如果觉得某个类的函数可能会需要修复,那么一定要把该类放到Editor目录下[Configure]类的[IFix]静态字段里;然后才可以对某个函数进行[IFix.Patch]。
- 涉及到interface和delegate,如果把一个虚拟机的类适配到原生interface或者把一个虚拟机的函数适配到原生delegate ,一定要放到[IFix.CustomBridge]类的静态字段里。
- 打上[Configure]标签的类,必须放在Editor目录下。
- [IFix],[Filter]这些标签必须放在打上[Configure]标签的类里。
- 在[IFix.Patch]时,不支持修复泛型函数,不支持修复构造函数,不支持在原生类中新增字段。
- 在[IFix.Interpret]时,不支持新增类继承原生类,不支持新增类是泛型类。





### 总结

| 标签 | 使用阶段 | 用途 | 用法 |
| :-----------------: | :------: | :------------------------: | :----------------------------------------------------------: |
| [IFix.Patch] | 补丁 | 修复函数 | 只能放在函数上 |
| [IFix.Interpret] | 补丁 | 新增字段,属性,函数,类型 | 放在字段,属性,函数,类型上 |
| [IFix.CustomBridge] | 注入 | interface和delegate桥接 | 只能放在单独写一个静态类上,存储虚拟机的类适配到原生interface或者虚拟机的函数适配到原生delegate,该类不能放Editor目录 |
| [Configure] | 注入 | 配置类 | 只能放在单独写一个存放在Editor目录下的类上 |
| [IFix] | 注入 | 可能需要修复函数的类的集合 | 只能放在[Configure]类的一个静态属性上 |
| [Filter] | 注入 | 不想发生注入的函数 | 只能放在[Configure]类的一个静态函数上 |

Loading