static string LuaCaller(int n, SharpLua.var[] argv) { string type = SharpLua.VarToString(argv[1]); //TODO NO Reflection Type MessageMgr = Assembly.GetExecutingAssembly().GetType("luamessage"); MethodInfo theMethod = MessageMgr.GetMethod(type); if (theMethod == null) { Debug.LogError("LuaCaller failed, no handler found:" + type); return(null); } object[] param = null; if (n > 2) { param = new object[n - 2]; for (int i = 2; i < n; i++) { param[i - 2] = SharpLua.VarValue(argv[i]); } } try { theMethod.Invoke(null, param); } catch (Exception ex) { Debug.LogError("LuaCaller invoke failed:" + ex.ToString()); return(null); } return(null); }
static string LuaPrint(int n, SharpLua.var[] argv) { string info = ""; for (int i = 1; i < n; i++) { info += SharpLua.VarToString(argv[i]) + "\t"; } Debug.Log(info); return(null); }
static string LuaLoader(int n, SharpLua.var[] argv) { if (argv.Length < 2) { return(null); } string path = SharpLua.VarToString(argv[1]); if (string.IsNullOrEmpty(path)) { return(null); } TextAsset script = Resources.Load(path) as TextAsset; if (script == null) { return(null); } argv[0].type = SharpLua.var_type.STRING; return(script.ToString()); }