暴露C++参数到蓝图
public:
//使得此参数可以被蓝图调用,但是无法改变
UPROPERTY(EditAnywhere,BlueprintReadOnly,Category= UI)
float Health_01;
//使得此参数可以被蓝图调用和改变
UPROPERTY(EditAnywhere,BlueprintReadWrite,Category= UI)
float Health_02;
在Rider中右键.cpp 文件空白处可以生成定义
暴露C ++ function到unreal蓝图:
在.h文件里:
UFUNCTION(BlueprintCallable,Category= UI)
void Print(FString Mystring);
UFUNCTION(BlueprintCallable,Category= UI)
bool Print2(FString Mystring);
cpp:
void ATestActor::Print(FString Mystring)
{
if(GEngine)
{
GEngine->AddOnScreenDebugMessage(-1,0.3f,FColor::Green,Mystring);
}
}
bool ATestActor::Print2(FString Mystring)
{
if(GEngine)
{
GEngine->AddOnScreenDebugMessage(-1,0.3f,FColor::Green,Mystring);
}
return false;
}
Editor里看到的效果:
创建纯函数:
h:这里BlueprintPure是关键
UFUNCTION(BlueprintCallable,BlueprintPure,Category= UI) bool Print3(FString Mystring);
cpp:
bool ATestActor::Print3(FString Mystring) { if(GEngine) { GEngine->AddOnScreenDebugMessage(-1,0.3f,FColor::Green,Mystring); } return false; }
在editor里看着是这样: