type.GetEvent或type.GetEvents不支持,怎么解决
System.Exception: can not load method [GetEvent] of System.Type
at IFix.Core.PatchManager.readMethod (System.IO.BinaryReader reader, System.Type[] externTypes) [0x00000] in
System.Exception: can not load method [GetEvent] of System.Type at IFix.Core.PatchManager.readMethod (System.IO.BinaryReader reader, System.Type[] externTypes) [0x00000] in :0 at IFix.Core.PatchManager.Load (System.IO.Stream stream) [0x00000] in :0
从代码这里看 array5[num7] 为空
Type type2 = array[binaryReader.ReadInt32()];
string text3 = binaryReader.ReadString();
array5[num7] = type2.GetField(text3, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (array5[num7] == null)
{
throw new Exception(string.Concat(new object[]
{
"can not load field [",
text3,
"] of ",
type2
}));
}
应该是unity剪裁了。
应该是unity剪裁了。
车神,如何避免这个问题呢
@work-hrf unity是不是设置strip了,可以关掉试试,或者link.xml加入保留类型
@work-hrf unity是不是设置strip了,可以关掉试试,或者link.xml加入保留类型
.Net底层API,只能通过link.xml来设置了吧。 因为手机包已经出了,如何在一个类里,清空另一个类中的事件呢,有没有其它办法。 public class B{ public static event Action onAttack = null;
public void Func11()
{
onAttack += (e)=>{Debug.Log("xxxx");};
}
}
[IFix.HotFix]//可热更类 public class A{ [IFix.Patch] void Func() { //因为strip选项导致无法通过如下方法来清理 EventInfo ei = typeof(B).GetEvent(); ei.RemoveEventHandler(); //--------------------如何在这个方法中 把onAttack事件清掉。---------------------- } }
由于event的限制,想通过外部修改,不用反射,貌似没其他好的办法了吧,除非B也支持热更
反射获取到那个event语法糖生成的字段,然后赋值为空即可。