public LuaReflection() { #if !MULTI_STATE _reflection = this; #endif LoadAssembly("mscorlib"); //LoadAssembly("UnityEngine"); //注释避免放在插件目录无法加载,需要可从lua代码loadassembly //LoadAssembly("Assembly-CSharp"); }
static int LoadAssembly(IntPtr L) { try { LuaReflection reflection = LuaReflection.Get(L); string name = ToLua.CheckString(L, 1); LuaDLL.lua_pushboolean(L, reflection.LoadAssembly(name)); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } return(1); }
static int FindType(IntPtr L) { string name = ToLua.CheckString(L, 1); LuaReflection reflection = LuaReflection.Get(L); List <Assembly> list = reflection.list; Type t = null; for (int i = 0; i < list.Count; i++) { t = list[i].GetType(name); if (t != null) { break; } } ToLua.Push(L, t); return(1); }