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
相关推荐
zhangzhangkeji10 天前
UE5 C++(71):文件是否存在,文件夹是否存在,FPaths :: FileExists( const FString & InPath) ;
ue5
妙为10 天前
UE5角色穿过石头穿模
ue5·unreal engine5·角色穿越石头·穿模
技术策划Boring11 天前
2025年工作复盘:开放世界3A项目配置管线与性能监控的探索
游戏·ue5·虚幻·p4·perforce
zhangzhangkeji13 天前
UE5 C++(70-2):定义成员函数 getCleanDirectory(..) 和枚举类 EFileDirectoryType,来获得目录
ue5
avi911114 天前
UE4-UE5虚幻引擎-前置学习三,优化,基础CPP
ue5·ue4·游戏开发·虚幻·游戏优化·游戏代码
zhangzhangkeji14 天前
UE5线程进阶(3-2):任务图的相关源码整理。 FGraphEvent 与 TGraphTask 的区别和联系
ue5
zhangzhangkeji16 天前
UE5线程进阶(3-1):
ue5
zhangzhangkeji16 天前
UE5线程进阶(2-3):enum ENamedThreads命名空间 :: Type : int32 { RHIThread = 0 } 是渲染硬件接口线程
ue5
zhangzhangkeji17 天前
UE5线程进阶(2-1):枚举类EAsyncExecution,作业类TAsyncRunnable、TAsyncQueuedWork,及全局线程函数 Async(..),及线程调用的 4 种方法总结
ue5
zhangzhangkeji18 天前
UE5线程进阶(1):
ue5