/// <summary> /// 快速调用方法 /// </summary> /// <typeparam name="T">返回值的类型</typeparam> /// <param name="methodName">方法名</param> /// <param name="param">方法参数组 例:new object[] { word, p, 3 };</param> /// <param name="paramtypes">方法参数类型组 例:new Type[] { typeof(string),typeof(char),typeof(int) }</param> /// <remarks>取得方法,然后快速调用</remarks> public T Invokermethod <T>(string methodName, object[] param, Type[] paramtypes) { // object obj = Activator.CreateInstance(objType);//根据类型创建实例 MethodInfo method = objType.GetMethod(methodName, paramtypes);//方法的名称 FastMethodInvoker.FastInvokeHandler fastInvoker = FastMethodInvoker.GetMethodInvoker(method); return((T)fastInvoker(objType, param)); }
public override void CacheMethod() { Type type = assembly.GetType(MainClassName); mainMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod(mainMethodName)); updateMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod(updateMethodName)); fixedUpdateMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod(fixedUpdateMethodName)); lateUpdateMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod(lateUpdateMethodName)); destroyMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod(destroyMethodName)); }
public override void Destroy() { if (destroyMethod != null) { destroyMethod.Invoke(null, null); } assembly = null; mainMethod = null; updateMethod = null; fixedUpdateMethod = null; lateUpdateMethod = null; destroyMethod = null; }
public void CacheMethod() { if (GameEnvironment.Instance.Platform == GamePlatform.iOS) { i_updateMethod = appdomain.LoadedTypes[MainClassName].GetMethod(updateMethodName, 0); i_fixedUpdateMethod = appdomain.LoadedTypes[MainClassName].GetMethod(fixedUpdateMethodName, 0); i_lateUpdateMethod = appdomain.LoadedTypes[MainClassName].GetMethod(lateUpdateMethodName, 0); } else { Type type = assembly.GetType("HotFixEnter"); m_mainMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod("Main")); m_updateMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod("Update")); m_fixedUpdateMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod("FixedUpdate")); m_lateUpdateMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod("LateUpdate")); m_DestroyMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod("Destroy")); } }
public void DestroyManager() { IsActiveMonoMethod = false; if (codeStream != null) { codeStream.Close(); codeStream = null; } if (appdomain != null) { appdomain.Invoke(MainClassName, "Destroy", null, null); appdomain = null; } if (assembly != null) { m_DestroyMethod.Invoke(null, null); assembly = null; } p0 = null; i_updateMethod = null; i_fixedUpdateMethod = null; i_lateUpdateMethod = null; m_mainMethod = null; m_updateMethod = null; m_fixedUpdateMethod = null; m_lateUpdateMethod = null; m_DestroyMethod = null; Instance = null; }