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
相关推荐
四代水门15 天前
UE5实现客户端与服务器时间同步
ue5
智海深蓝17 天前
海上平行战场:态势模拟三维可视化平台
3d·ue5
_守一18 天前
UE5 ListView记录
ue5
成都渲染101云渲染666618 天前
CR15新功能介绍以及CR15云渲染流程
ue5·图形渲染·blender·maya·corona
一锅炖出任易仙19 天前
创梦汤锅学习日记day30
学习·ai·ue5·游戏引擎
OSwich19 天前
【UE5学习笔记】UMG中控件命名规范
笔记·学习·ue5
一锅炖出任易仙20 天前
创梦汤锅学习日记day29
学习·ai·ue5·游戏引擎
吴梓穆20 天前
UE5 C++ 注册 开始重叠和结束重叠事件
开发语言·c++·ue5
妙为21 天前
unreal engine5(UE5)中使用Rider
ue5·游戏引擎·虚幻·rider
归真仙人23 天前
【UE】LineTraceByProfile
ue5·游戏引擎·ue4·unreal engine