[UE4]BlueprintNativeEvent的用途

 

官方的解释是,如果定义函数UFUNCATION时使用BlueprintNativeEvent标识,表示期望该函数在蓝图被重写(override)(这里的重写指的是定义一个自定义事件Custom Event),同时又拥有C++的实现方法,那么定义函数时,除了自身的方法名以外,还需要加一个后缀_Implementation,并在C++实现这个函数“函数名_Implementation”,比如就这样定义:

/** Override in BPs to power up bombs. */
UFUNCTION(BlueprintNativeEvent, Category = "Game")
int32 AAAA();
int32 AAAA_Implementation();

 

这样定以后,会优先调用蓝图中的Event,如果蓝图中该Event没有方法体,则调用C++的方法_Implementation。

 

如果要在蓝图脚本中实现该函数,打开蓝图 -》 我的蓝图 -》 Function -》 Override,找到之前在代码中定义的函数:


 

 

官方文档:

BlueprintNativeEvent

扫描二维码关注公众号,回复: 487248 查看本文章

https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Functions/Specifiers/BlueprintNativeEvent/index.html

 

C++ and Blueprints

https://docs.unrealengine.com/latest/INT/Gameplay/ClassCreation/CodeAndBlueprints/index.html

 

猜你喜欢

转载自aigo.iteye.com/blog/2269592
UE4