目录
BlueprintPure 蓝图纯函数(无执行线,必须要有返回值)
BlueprintImplementableEvent 蓝图可实现事件(覆盖C++)
BlueprintNativeEvent 蓝图原生事件(C++必须实现,蓝图也可以实现)
- UFUNCTION([specifier1=setting1, specifier2, ...], [meta(key1="value1", key2, ...)])
- ReturnType FunctionName([Parameter1, Parameter2, ..., ParameterN1=DefaultValueN1, ParameterN2=DefaultValueN2]) [const];
- UFUNCTION(BlueprintCallable, Category="methods")
- void FunBlueprintCallable1();
-
- UFUNCTION(BlueprintCallable, Category = "methods")
- bool FunBlueprintCallable2(FString Path,float input1, const float& input2, float& output, TArray
Points1, const TArray& Points2, TArray& Position ) ;
- UFUNCTION(BlueprintPure, Category = "methods")
- float FunBlueprintPure1();
-
- UFUNCTION(BlueprintPure, Category = "methods")
- void FunBlueprintPure2(float& Value);
- UFUNCTION(BlueprintImplementableEvent, Category = "methods")
- void FunBlueprintImplementableEvent1();
-
- UFUNCTION(BlueprintImplementableEvent, Category = "methods")
- void FunBlueprintImplementableEvent2(float& Value);
_Implementation
的返回值和参数列表都一致的函数.- //DisplayName 蓝图中实际调用的函数名
- //DeprecationMessage显示警告信息
- //此处参数用Fsting str 编译不通过
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "methods", meta=(DisplayName="FunBlueprintNativeEvent测试",DeprecatedFunction, DeprecationMessage = "This FunBlueprintNativeEvent 的测试."))
- void FunBlueprintNativeEvent(const FString& str="From C++");
- void AMyActor::FunBlueprintNativeEvent_Implementation(const FString& str)
- {
- GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Blue, str);
- }
此函数可从游戏中的控制台中执行。Exec命令仅在特定类中声明时才产生作用。包括:
- UFUNCTION(Exec, Category = "methods")
- void FunExec(float Value);
- void AMyPawn::FunExec(float Value)
- {
- GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Blue, FString::Printf(TEXT("BPNative C++ Call Value:%f"), Value));
- }
- UENUM(BlueprintType)
- enum class BranchOutput : uint8
- {
- Branch0,
- Branch1,
- Branch2,
- };
-
- UFUNCTION(BlueprintCallable, Category = "methods", Meta = (ExpandEnumAsExecs = "Branches"))
- void FunExpandEnumAsExecs(int32 Input, BranchOutput& Branches);
- void AMyActor::FunExpandEnumAsExecs(int32 Input, BranchOutput& Branches)
- {
- if (Input == 0){
- Branches = BranchOutput::Branch0;
- }
- else if(Input == 1){
- Branches = BranchOutput::Branch1;
- }
- else{
- Branches = BranchOutput::Branch2;
- }
- }
参考链接:
虚幻引擎UFunction | 虚幻引擎5.0文档 (unrealengine.com)
【UE4 C++ 基础知识】<2> UFUNCTION宏、函数说明符、元数据说明符 - 砥才人 - 博客园 (cnblogs.com)