update: 2016/11/17
reference:
1. Calling Blueprint Functions from C++ | 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
A. 新增巨集屬性的函數
1. 接續 I touchs: Unreal: Exposing C++ functions to Blueprints 的專案
2. 在 MyActor.h 的類別定義內定義函數:
....
//@add ######
UFUNCTION(BlueprintImplementableEvent, Category = "Output")
void PrintOnScreen(int32 IntToPrint);
....
....
// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
Super::BeginPlay();
//@add ####
this->PrintOnScreen(7);
}
....
4. 存檔並編譯
-----------------------------------------------------------------------------------------------
B. 開啟繼承 MyActor 類別的 Blueprint Class
1. 點選 BP_MyActor, 雙擊滑鼠以開啟
2. 切換到 Event Graph 頁籤, 點選 Function > Override > Print on Screen
C. 回到關卡場景
1. 將 BP_MyActor 拖拉到場景內
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。