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
相关推荐
归真仙人2 天前
【UE】LineTraceByProfile
ue5·游戏引擎·ue4·unreal engine
-FxYaM-3 天前
【UE】渲染框架学习路径-初次修改源码
服务器·网络·c++·windows·ue5·unreal engine
一锅炖出任易仙5 天前
创梦汤锅学习日记day23
学习·ai·ue5
妙为7 天前
unreal engine5.7.4,创建ThirdPerson第三人称模版,类型是c++崩溃
c++·ue5·虚幻·unreal engine5
weixin_4046793110 天前
虚幻5电子书
ue5
directx3d_beginner11 天前
5,动画蓝图类接口转c++
ue5
RuiZN11 天前
UE5 蓝图 FPS 02 Event Beginplay
c++·ue5
RuiZN11 天前
UE5 蓝图 FPS 01 Event Tick
c++·ue5
directx3d_beginner11 天前
6,执行攻击改为c++
ue5
平行云12 天前
实时云渲染预启动技术解析:UE数字孪生应用的延迟优化机制(二)
linux·unity·ue5·webgl·实时云渲染·云桌面·像素流