From 088e7767264e901482dfeb2a34cedc08d0f218e8 Mon Sep 17 00:00:00 2001 From: Makstein <1105515416@qq.com> Date: Mon, 23 Sep 2024 09:59:46 +0800 Subject: [PATCH] Create 2024-09-14-UE5 BlueprintNativeEvents.md --- .../2024-09-14-UE5 BlueprintNativeEvents.md | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 _posts/2024-09-14-UE5 BlueprintNativeEvents.md diff --git a/_posts/2024-09-14-UE5 BlueprintNativeEvents.md b/_posts/2024-09-14-UE5 BlueprintNativeEvents.md new file mode 100644 index 00000000000..7183f677649 --- /dev/null +++ b/_posts/2024-09-14-UE5 BlueprintNativeEvents.md @@ -0,0 +1,38 @@ +--- +title: UE5 BlueprintNativeEvents +date: 2024-09-14 15:52 +0800 +categories: + - Game Development + - Unreal Engine +tags: + - ue + - ufunction +--- +**BlueprintNativeEvents** 是 **UFUNCTION** 的一个函数说明符,作用是指定一个函数,使其可以在C++中实现,并且同时可以在蓝图中被重载 + +与 **BlueprintImplementableEvents** 不同,它不仅可以有蓝图实现,而且可以拥有一个C++实现 + +## 具体使用 + +```cpp +///Header (.h) function definition: +//Override in BP to extend the base C++ functionality! +UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category="JoyBall") +float GetArmorRating() const; + +///////////////// + +///Source (.cpp) function Implementation: +float AJoyBall::GetArmorRating_Implementation() const +{ + //remember to call super / parent function in BP! + V_LOG("C++ Happens First"); + return 100; +} +``` + +在蓝图重载函数中,可以调用父函数来使用C++的实现,并在此基础上进行扩展,或者不调用父函数,完全重写此函数 + +## 参考 + +[Tutorial: BlueprintNativeEvents Unreal Engine Community Wiki (unrealcommunity.wiki)](https://unrealcommunity.wiki/blueprints-empower-your-entire-team-with-blueprintnativeevents-x4fs54ut) \ No newline at end of file