以下代码来自xLua demo,这里只是做进一步说明。
一、创建lua文件
function start()
print("lua start...")
-- 这里的Button是UGUI控件
self:GetComponent("Button").onClick:AddListener(function()
print("clicked, you input is '" ..input:GetComponent("InputField").text .."'")
end)
end
工程截图
运行测试