static int AddPartEvent(IntPtr L) { try { ToLua.CheckArgsCount(L, 5); LuaBehaviour obj = (LuaBehaviour)ToLua.CheckObject(L, 1, typeof(LuaBehaviour)); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.GameObject)); LuaFunction arg1 = ToLua.CheckLuaFunction(L, 3); System.Collections.Generic.Dictionary <string, LuaInterface.LuaFunction> arg2 = (System.Collections.Generic.Dictionary <string, LuaInterface.LuaFunction>)ToLua.CheckObject(L, 4, typeof(System.Collections.Generic.Dictionary <string, LuaInterface.LuaFunction>)); UITriggerListener.VoideDelegate arg3 = null; LuaTypes funcType5 = LuaDLL.lua_type(L, 5); if (funcType5 != LuaTypes.LUA_TFUNCTION) { arg3 = (UITriggerListener.VoideDelegate)ToLua.CheckObject(L, 5, typeof(UITriggerListener.VoideDelegate)); } else { LuaFunction func = ToLua.ToLuaFunction(L, 5); arg3 = DelegateFactory.CreateDelegate(typeof(UITriggerListener.VoideDelegate), func) as UITriggerListener.VoideDelegate; } obj.AddPartEvent(arg0, arg1, arg2, ref arg3); ToLua.Push(L, arg3); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// 事件处理 /// </summary> /// <param name="go"></param> /// <param name="luafunc"></param> /// <param name="mCallbacks"></param> /// <param name="delEvent"></param> public void AddPartEvent(GameObject go, LuaFunction luafunc, Dictionary <string, LuaFunction> mCallbacks, ref UITriggerListener.VoideDelegate delEvent) { if (!mCallbacks.ContainsKey(go.name)) { mCallbacks.Add(go.name, luafunc); //UITriggerListener listener = go.GetComponent<UITriggerListener>(); //if (listener == null) // listener = go.AddComponent<UITriggerListener>(); //Debug.Log("event:" + delEvent); delEvent = delegate(PointerEventData eventData) { //object[] eventDataObj = new[] {eventData}; luafunc.BeginPCall(); luafunc.Push(go); luafunc.PushArgs(new object[] { eventData }); //luafunc.Push(eventData); luafunc.PCall(); luafunc.EndPCall(); }; } }