UE4/UE5 使用C++ 暴露FunctionLibrary 蓝图函数调用

// .h文件中
 
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBPCallFunction.generated.h"
 
 
 
DEFINE_LOG_CATEGORY_STATIC(myLog, Log, All);
//UE_LOG(myLog,Log,TEXT("name = %s"),*customName);
 

UCLASS()
class CREATEBPLINKLIB_API UMyBPCallFunction : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()
 
 
public:
    UFUNCTION(BlueprintCallable,Category="Custom|myfun")
    static void GetCustomName(FString& myName);
     
     UFUNCTION(BlueprintCallable,Category="Custom|myfun")
    static void SetCustomName(FString setName,FString& custom);
};
  


//.cpp中
 
#include "Public/MyBPCallFunction.h"
 
void UMyBPCallFunction::GetCustomName(FString& myName)
{
    myName = "hello!";
}
 
 
void UMyBPCallFunction::SetCustomName(FString setName,FString& customName)
{
    //customName = setName;
    customName = setName.Append("abc");
    UE_LOG(myLog,Log,TEXT("name = %s"),*customName);
}

猜你喜欢

转载自blog.csdn.net/qq_21153225/article/details/124300619