经研究 tolua 没有封装好的 Ui点击事件 只能去自定义 事件添加
首先在导出工具中添加自己的 delegate 导出表中
_DT(typeof(UnityEngine.Events.UnityAction)),
_DT(typeof(UnityEngine.Events.UnityAction<float>)),
function handler(obj,method)
return function(...)
return method(obj,...)
end
end
local event = UnityEngine.Events.UnityAction_float(handler(self,self.callbackFun))
Event.addListener(slider,event )
Event 为自己定义的类
addListener 自己定义的方法
public static void addListener(Component obj , UnityEngine.Events.UnityAction<float> call)
{
if(obj == null || call == null)
{
return;
}
if(obj.GetType() == typeof(Slider))
{
Slider slider = (Slider) obj;
slider.onValueChanged.AddListener(call);
}
}