UnLua调用蓝图变量、动画、函数

一、调用蓝图声明的变量

1、在蓝图中声明一个String类型变量title

默认值为MyFirstTitle

2、在UnLua中调用

lua 复制代码
function WBP_FirstLua_C:Construct()
	print("Title~"..self.title)
end

二、绑定蓝图的UMG组件

1、在蓝图中制作按钮btnTest

2、在Lua中绑定该按钮的点击事件

lua 复制代码
function WBP_FirstLua_C:Construct()
	--添加按钮事件
	self.btnTest.OnPressed:Add(self,WBP_FirstLua_C.OnClickTest)
end

function WBP_FirstLua_C:OnClickTest()
	print("OnClickTest")
end

三、播放蓝图的动画

1、在蓝图中制作UI动画

2、在Lua中播放该动画

lua 复制代码
function WBP_FirstLua_C:Construct()
	--播放UMG中定义的UI动画
	self:PlayAnimation(self.AnimShowBtn,0,1)
end

四、调用蓝图的函数

1、在蓝图中定义播放UI动画的函数

2、在Lua中调用该函数

lua 复制代码
function WBP_FirstLua_C:Construct()
	--调用蓝图中自定义事件
	self:ShowButton()
end
相关推荐
StarTechnology19 小时前
UE5云渲染管理平台-支持私有化部署Linux-Windows国产化适配
ue5·webui·webbrowser
平行云21 小时前
实时云渲染信创架构解析:从GPU池化到全栈适配的技术演进
linux·unity·docker·ue5·webgl·数字孪生·实时云渲染
远离UE42 天前
UE5 高性能 实时 玻璃破碎系统
ue5
远离UE43 天前
UE5 多线程 与 异步 并行
ue5
日月云棠6 天前
UE5源码分析之Editor——ConfigEditor模块全面分析
ue5
日月云棠7 天前
UE5源码分析之Editor——CommonMenuExtensions插件全面分析
ue5
日月云棠7 天前
UE5源码分析之Editor——ClothingSystemEditorInterface模块全面分析
ue5
日月云棠7 天前
UE5源码分析之Editor——ClothPainter插件全面分析
ue5
[苦行僧]7 天前
ue5 异步 Task
ue5
曼巴UE510 天前
Unlua UE5.3 调试
ue5·lua·unlua