[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,找到之前在代码中定义的函数:

[UE4]BlueprintNativeEvent的用途_第1张图片
 

 

官方文档:

BlueprintNativeEvent

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

 

 

你可能感兴趣的:(UE4)