腾讯XLua 02-UI事件与事例API

local speed = 10
--XLua中 函数的映射关系

function start()
    --Button组件添加监听事件
    self:GetComponent("Button").onClick:AddListener(function()
        print("clicked, you input is '" ..input:GetComponent("InputField").text .."'")
    end)
end

function awake()
    CS.UnityEngine.Debug.Log("This is awake function")
end

function update()
    -- body
end

function ondestroy()
    CS.UnityEngine.Debug.Log("This is destroy function")
end

--常用的API
--1.打印输出
--CS.UnityEngine.Debug.Log("This is destroy function")
--2.获得组件
--self:GetComponent("Button")
--3.给lua脚本传参数
--Inspector面板有个 Injections 设置Size 绑定对应的控件 在lua中可以根据名字调用组件

你可能感兴趣的:(Unity知识要点)