2016年11月17日 星期四

Unreal: Create C++ Blueprint Function Library

since: 2016/11/17
update: 2016/11/17

reference:
1. Understanding the Blueprint Function Library | Orfeas Eleftheriou
2. I touchs: Unreal: Adding a C++ Class
3. I touchs: Unreal: Exposing C++ variables to Blueprints
4. I touchs: Unreal: Exposing C++ functions to Blueprints
5. I touchs: Unreal: Add Override C++ Event Functions in Blueprints


A. 新增 C++ 類別
    1. 可以接續 Unreal: Add Override C++ Event Functions in Blueprints 的專案

    2. Add New > New C++ Class...

    3. 選擇 "Blueprint Function Library" 作為 Parent Class > Next

    4. 幫新增的 Class 命名: MyHelperFunctions > Create Class

-----------------------------------------------------------------------------------------------

B. 新增函式宣告與內容:
    1. 修改: MyHelperFunctions.h
....
class HELLOCPP_API UMyHelperFunctions : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()


        public:
        //@add ######
        UFUNCTION(BlueprintCallable, Category = "MyOwnBlueprintFunctionLibrary")
        void UsefulFunction();
};
....


    2. 修改: MyHelperFunctions.cpp
....
//@add ######

void UMyHelperFunctions::UsefulFunction()
{
    //TODO
}
....

     3. 存檔編譯

-----------------------------------------------------------------------------------------------


C. 從任何 Blueprint 呼叫函式:
     1. 開啟任何 Blueprint (在此為 Level Blueprint)

     2. 切換到 Event Graph 頁籤 > 取消勾選: Context Sensitive
         > 選取搜尋到的 UsefulFunction

     3. 結果:

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。