コード例 #1
0
 private void OnButtonsClickHandle(GameObject go)
 {
     if (buttons.ContainsKey(go))
     {
         LuaBehaviourData data = buttons[go];
         if (data.Args != null && data.Args.Length == 1)
         {
             data.LuaFunc.Call(data.LuaTable, go, data.Args[0]);
         }
         else
         {
             data.LuaFunc.Call(data.LuaTable, go);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// 删除单击事件
        /// </summary>
        /// <param name="go"></param>
        public void RemoveClick(GameObject go)
        {
            if (go == null)
            {
                return;
            }
            LuaBehaviourData data = null;

            if (buttons.TryGetValue(go, out data))
            {
                UIEventListener.Get(go).onClick -= OnButtonsClickHandle;
                buttons.Remove(go);
                data.LuaFunc.Dispose();
                data.LuaFunc = null;
            }
        }
コード例 #3
0
        /// <summary>
        /// 添加单击事件
        /// </summary>
        public void AddClick(GameObject go, LuaTable luaTable = null, LuaFunction luafunc = null, params object[] args)
        {
            if (go == null || luaTable == null || luafunc == null)
            {
                return;
            }
            if (buttons.ContainsKey(go))
            {
                RemoveClick(go);
            }
            LuaBehaviourData data = new LuaBehaviourData();

            data.LuaTable = luaTable;
            data.LuaFunc  = luafunc;
            data.Args     = args;
            buttons.Add(go, data);
            UIEventListener.Get(go).onClick += OnButtonsClickHandle;
        }