UnLua扩展接口

一、在蓝图中创建接口

1、创建BlueprintInterface

2、声明接口函数

3、继承接口

注意,接口不需要绑定Lua,也没有Bind按钮
二、在Lua中实现接口函数

1、实现接口函数

BP_Player.lua

lua 复制代码
function BP_Player_C:UpdateAiming(IsAiming)
	if IsAiming then
		self.ZoomInOut:Play()		--0变化到1
	else
		self.ZoomInOut:Reverse()	--1变化到0
	end
end

2、调用接口函数

BP_PlayerController.lua

lua 复制代码
function BP_PlayerController_C:Aim_Pressed()
	--self.Pawn:UpdateAiming(true)	--FOV增加,广角

	--local MyInterface = UE.UBPI_Interfaces_C 	--获取Interface元表,弃用
	--MyInterface.UpdateAiming(self.Pawn,true)	--弃用
	local BPI_Interfaces = UE.UClass.Load("/Game/ShootingScripts/Blueprint/Common/BP_Interfaces.BP_Interfaces_C")
	BPI_Interfaces.UpdateAiming(self.Pawn,true)
end
相关推荐
AA陈超18 小时前
枚举类 `ETriggerEvent`
开发语言·c++·笔记·学习·ue5
曼巴UE518 小时前
UE C++ UI的折叠动画,隐藏收缩经验分享
c++·ue5
AA陈超1 天前
Lyra Starter Game 中 GameFeature 类(如 ShooterCore)的加载流程
c++·笔记·学习·ue5·虚幻引擎
会思考的猴子1 天前
UE5 监听设备输入
ue5
平行云2 天前
Enscape × Paraverse | 从设计到一键发布、网页分享、实时交互的全新体验
unity·ue5·xr·3dsmax·webgl·实时云渲染·云桌面
吴梓穆2 天前
UE5 无边框全屏幕无法全屏
ue5
zhangzhangkeji2 天前
cesium126,230612,对齐模型到地理位置:添加锚点。以及如何恰当的移动 UE 坐标原点,georefer 的位置。BIM,CIM
ue5
成都渲染101云渲染66662 天前
三维制图软件哪个最好用?主流 3D 建模软件深度对比(2025)
3d·ue5·图形渲染·blender·maya·houdini
会思考的猴子2 天前
UE5 中导入下载的场景素材
ue5
会思考的猴子2 天前
UE5 笔记 动画播放
ue5