public static InputButtonClickRegisterInfo GetOnClickListener(Button button, string UIName, string ComponentName, string parm, InputEventHandle <InputUIOnClickEvent> callback)
    {
        InputButtonClickRegisterInfo info = HeapObjectPool <InputButtonClickRegisterInfo> .GetObject();

        info.eventKey  = InputUIOnClickEvent.GetEventKey(UIName, ComponentName, parm);
        info.callBack  = callback;
        info.m_button  = button;
        info.m_OnClick = () =>
        {
            DispatchOnClickEvent(UIName, ComponentName, parm);
        };

        return(info);
    }
Exemple #2
0
    //TODO 逐步添加所有的移除监听方法

    public InputEventRegisterInfo <InputUIOnClickEvent> GetClickRegisterInfo(string buttonName, InputEventHandle <InputUIOnClickEvent> callback, string parm)
    {
        string eventKey = InputUIOnClickEvent.GetEventKey(UIEventKey, buttonName, parm);

        for (int i = 0; i < m_OnClickEvents.Count; i++)
        {
            if (m_OnClickEvents[i].eventKey == eventKey &&
                m_OnClickEvents[i].callBack == callback)
            {
                return(m_OnClickEvents[i]);
            }
        }

        throw new Exception("GetClickRegisterInfo Exception not find RegisterInfo by " + buttonName + " parm " + parm);
    }
Exemple #3
0
 static int GetEventKey(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         string arg0 = ToLua.CheckString(L, 1);
         string arg1 = ToLua.CheckString(L, 2);
         string arg2 = ToLua.CheckString(L, 3);
         string o    = InputUIOnClickEvent.GetEventKey(arg0, arg1, arg2);
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #4
0
    public static InputEventRegisterInfo <InputUIOnClickEvent> AddOnClickListener(Button button, string UIName, string ComponentName, string parm, InputEventHandle <InputUIOnClickEvent> callback)
    {
        InputButtonClickRegisterInfo info = new InputButtonClickRegisterInfo();

        info.eventKey  = InputUIOnClickEvent.GetEventKey(UIName, ComponentName, parm);
        info.callBack  = callback;
        info.m_button  = button;
        info.m_OnClick = () =>
        {
            DispatchClickEvent(UIName, ComponentName, parm);
        };

        info.AddListener();

        button.onClick.AddListener(info.m_OnClick);

        return(info);
    }