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
相关推荐
远离UE42 小时前
UE5 GPU内部异步
ue5
1204157137 肖哥2 小时前
UE5 PCG PCGBlueprintElement简介
ue5
dong1326972 小时前
UE5FPS游戏开发教程(四)
ue5
dong13269720 小时前
UE5FPS游戏开发教程(三)
ue5
日月云棠21 小时前
UE5源码分析之Editor——AnimationBlueprintLibrary模块全面分析
ue5
远离UE41 天前
UE5 ECS 原理
ue5
mengzhi啊3 天前
UE5 把剑绑定到骨骼-给要播放的动画及动画蒙太奇添加武器
ue5
directx3d_beginner3 天前
32,每帧更新怪物朝向改为c++
ue5
日月云棠3 天前
UE5源码分析之Editor——AnimationEditor模块全面分析
ue5
吴梓穆4 天前
UE5 播放透明视频
ue5