static void ResetInstruction(MonoXIL.Cecil.Cil.MethodBody body) { int offset = 0; var instructions = body.Instructions; wxb.RefType refType = new RefType(instructions); var items = (Instruction[])refType.GetField("items"); var count = instructions.Count; var stack_size = 0; var max_stack = 0; Dictionary <Instruction, int> stack_sizes = null; if (body.HasExceptionHandlers) { ComputeExceptionHandlerStackSize(body, ref stack_sizes); } for (int i = 0; i < count; i++) { var instruction = items[i]; instruction.Offset = offset; offset += instruction.GetSize(); ComputeStackSize(instruction, ref stack_sizes, ref stack_size, ref max_stack); } wxb.RefType body_refType = new RefType(body); body_refType.SetField("code_size", offset); body_refType.SetField("max_stack_size", max_stack); }
static void Start(HelloWorld world) { UnityEngine.Debug.LogFormat("!!!Hot Start(HelloWorld world)"); RefType refType = new RefType((object)world); refType.GetField <List <string> >("onTexts").Add("HotHelloWorld Start"); __Hotfix_Start.Invoke(world); // 调回HelloWorld.Start自身接口 }
static void OnGUI(HelloWorld world) { UnityEngine.GUILayout.Label("这里是补丁里的逻辑处理!!!"); RefType refType = new RefType((object)world); var texts = refType.GetField <List <string> >("onTexts"); foreach (var ator in texts) { UnityEngine.GUILayout.Label(ator); } }
static void Start(HelloWorld world) { //Vector2 a = new Vector2(1, 2); //Vector2 b = new Vector2(3, 4); //var c = a + b; //Vector4 v = new Vector4(1, 2); //Vector4 v1 = new Vector4(1, 2,3); //Vector4 v2 = new Vector4(1, 2, 3, 4); //UnityEngine.Debug.Log($"v:{v} v1:{v1}, v2:{v2}"); //Vector4 v4 = new Vector4(1,2,3,4); //Vector2 v2 = v4; //Vector3 v3 = v4; //UnityEngine.Debug.Log($"v2:{v2}, v3:{v3} v4:{v4}"); Vector2Int a = new Vector2Int(1, 2); UnityEngine.Debug.Log($"down :{Vector2Int.down}"); UnityEngine.Debug.Log($"up :{Vector2Int.up}"); UnityEngine.Debug.Log($"one :{Vector2Int.one}"); UnityEngine.Debug.Log($"zero :{Vector2Int.zero}"); UnityEngine.Debug.Log($"left :{Vector2Int.left}"); UnityEngine.Debug.Log($"right :{Vector2Int.right}"); UnityEngine.Debug.Log($"a[0] :{a[0]}"); UnityEngine.Debug.Log($"a[1] :{a[1]}"); UnityEngine.Debug.LogFormat("Hot Start(HelloWorld world)"); RefType refType = new RefType((object)world); refType.GetField <List <string> >("onTexts").Add("HotHelloWorld Start"); ITestInterface hti = new TestInterface(); hti.Test(); __Hotfix_Start.Invoke(world); // 调回HelloWorld.Start自身接口 }