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
相关推荐
ue星空4 小时前
在虚幻引擎中实现Camera Shake 相机抖动/震屏效果
ue5·虚幻·虚幻引擎
UTwelve6 小时前
【UE5】将2D切片图渲染为体积纹理,最终实现使用RT实时绘制体积纹理【第四篇-着色器投影-接收阴影部分】
ue5·虚幻·着色器
UTwelve8 小时前
【UE5】将2D切片图渲染为体积纹理,最终实现使用RT实时绘制体积纹理【第二篇-着色器制作】
ue5·游戏引擎·虚幻·着色器·虚幻4
ue星空1 天前
将Mixamo的模型和动画导入UE5
游戏·ue5·游戏引擎·虚幻·虚幻引擎
我的巨剑能轻松搅动潮汐1 天前
UE5 Windows热更新解决方案思路(HotPatcher+Tomcat+RuntimeFilesDownloader)
ue5
ue星空2 天前
在虚幻引擎中创建毛发/头发
游戏·ue5·游戏引擎·虚幻·虚幻引擎
UTwelve2 天前
【UE5】将2D切片图渲染为体积纹理,最终实现使用RT实时绘制体积纹理【第三篇-着色器光照】
ue5·ue4·虚幻·着色器
ue星空3 天前
UE5地图白屏/过曝/非常亮の解决方法
ue5·虚幻
ue星空3 天前
虚幻引擎的三种输入模式和将控件显示到屏幕上
ue5·游戏引擎·虚幻·虚幻引擎