通過繼承UBlueprintFunctionLibrary的類實現藍圖與C++相互通信

UMyBPFunctionLibrary中的方法爲靜態方法

UMyBPFunctionLibrary.h

UCLASS()
class  UMyBPFunctionLibrary : public UBlueprintFunctionLibrary
{
    GENERATED_UCLASS_BODY()
public:

    UFUNCTION(BlueprintCallable, Category = "MyFunction|MyClass")
        static void Method1();

    UFUNCTION(BlueprintCallable, Category = "MyFunction|MyClass")
        static void Method2();

    UFUNCTION(BlueprintCallable, Category = "MyFunction|MyClass")
        static void Method3();
};
UMyBPFunctionLibrary.cpp

UMyBPFunctionLibrary::UMyBPFunctionLibrary(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{

}

void UMyBPFunctionLibrary::Method1()
{

}

void UMyBPFunctionLibrary::Method2()
{

}

void UMyBPFunctionLibrary::Method3()
{

}

這樣藍圖中就可以調用c++中方法method1、method2、method3,方便藍圖與c++交互。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章