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和unlua对于同一个对象的协同处理
ue5
归真仙人3 天前
【UE】Lightmass可执行文件已经过时
ue5·游戏引擎·ue4·虚幻·unreal engine
DoomGT3 天前
Design - 一些免费图标网站
ue5·ue4·虚幻·虚幻引擎·unreal engine
晴夏。4 天前
UE5 GASP技术浅析
ue5·gasp
邪修king4 天前
UE5 TA 核心修炼:材质与纹理艺术全解 —— 从 PBR 理论到工业级材质实战
c++·后端·游戏·ue5·材质
SCLchuck4 天前
UE5 地形材质UV
ue5·材质·uv
UTwelve5 天前
【UE】材质与半透明 - 01. 基于Masked遮罩的抖动半透明 DitherMask
ue5·材质·虚幻引擎·着色器
晴夏。5 天前
UE5 motion warping 运动扭曲的用途
运维·ue5
蓝图大法5 天前
ue5 血条 渲染方形的分辨率 血条缩放的问题
ue5