void CallMethod(KeyCode key, bool bDown) { if (!SLua.LuaSvr.inited || null == SLua.LuaSvr.mainState) { return; } SLua.LuaState l = SLua.LuaSvr.mainState; SLua.LuaFunction func = l.getFunction("OnHotKeyInput"); if (null != func) { func.call(key, bDown); func.Dispose(); } }
static bool ReportLog(LogType type, string str) { if (!SLua.LuaSvr.inited || null == SLua.LuaSvr.mainState) { return(false); } SLua.LuaState l = SLua.LuaSvr.mainState; if (null == l) { return(false); } SLua.LuaFunction func = l.getFunction("OnUnityLog"); if (null != func) { func.call(new object[] { type, str }); func.Dispose(); return(true); } return(false); }
void InitKeyCodeMap() { if (bInited) { return; } if (null == LuaSvr.main || !LuaSvr.main.inited || null == LuaSvr.main.luaState) { return; } SLua.LuaState l = SLua.LuaSvr.main.luaState; if (null == l) { return; } bInited = true; SLua.LuaFunction func = l.getFunction("OnHotKeyCodeMap"); if (null != func) { LuaTable ret = func.call() as LuaTable; foreach (var obj in ret) { object value = obj.value; int ival = Convert.ToInt32(value); KeyCode key = (KeyCode)Enum.ToObject(typeof(KeyCode), ival); if (!sKeyCodeMap.ContainsKey(key)) { sKeyCodeMap.Add(key, true); } else { sKeyCodeMap[key] = true; } } func.Dispose(); } }
public static void ReleaseLuaFn(LuaFunction fn) { if (fn != null) fn.Dispose(); }