Open jinghuafumen opened 4 years ago
using System.Collections; using UnityEngine;
public class ZTest : MonoBehaviour { void Start() { Test(); }
[IFix.Patch] void Test() { StartCoroutine(TestCoroB()); } IEnumerator TestCoroA() { yield return null; Debug.Log("TestCoroA"); } [IFix.Interpret] IEnumerator TestCoroB() { yield return new WaitForSeconds(1); Debug.Log("TestCoroB"); }
}
//如果代码里有TestCoroA,新增TestCoroB,没问题 //如果把TestCoroA删了,再新增TestCocoB,会报错 //报错提示: // KeyNotFoundException: The given key was not present in the dictionary. // System.Collections.Generic.Dictionary2[System.Reflection.MethodInfo,System.Int32].get_Item (System.Reflection.MethodInfo key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150) // IFix.Core.PatchManager.readSlotInfo (System.IO.BinaryReader reader, System.Collections.Generic.Dictionary2 itfMethodToId, System.Type[] externTypes, Int32 maxId) // IFix.Core.PatchManager.Load (System.IO.Stream stream)
2[System.Reflection.MethodInfo,System.Int32].get_Item (System.Reflection.MethodInfo key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150) // IFix.Core.PatchManager.readSlotInfo (System.IO.BinaryReader reader, System.Collections.Generic.Dictionary
如果之前有过返回 IEnumerator 类型的函数,那[IFix.Interpret]就没问题; 如果之前没有过,就得手动加个接口,把 IEnumerator 放到[IFix.CustomBridge]里。
using System.Collections; using UnityEngine;
public class ZTest : MonoBehaviour { void Start() { Test(); }
}
//如果代码里有TestCoroA,新增TestCoroB,没问题 //如果把TestCoroA删了,再新增TestCocoB,会报错 //报错提示: // KeyNotFoundException: The given key was not present in the dictionary. // System.Collections.Generic.Dictionary
2[System.Reflection.MethodInfo,System.Int32].get_Item (System.Reflection.MethodInfo key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150) // IFix.Core.PatchManager.readSlotInfo (System.IO.BinaryReader reader, System.Collections.Generic.Dictionary
2 itfMethodToId, System.Type[] externTypes, Int32 maxId) // IFix.Core.PatchManager.Load (System.IO.Stream stream)