UPROPERTY
设置可视
//仅在类默认设置可见(即里面面板)
UPROPERTY(VisibleDefaultsOnly)
int32 VisibleDefaultsOnlyInt;
//仅在实例化细节面板可见(即外面面板)
UPROPERTY(VisibleInstanceOnly)
FString VisibleInstancestring;
//类默认设置和实例化细节面板都可见
UPROPERTY(VisibleAnywhere)
FVector VisibleAnywhereVector;
在类的设置里面会显示,但是无法编辑
设置可编辑
//仅在类默认设置里面编辑
UPROPERTY(EditDefaultsOnly)
int32 EditDefaultOnlyInt;
//仅在实例化细节面板编辑
UPROPERTY(EditInstanceOnly)
FString EditInstanceOnlyString;
//仅在类默认设置和实例化都可以编辑
UPROPERTY(EditAnywhere)
FVector EditAnywhereVector;
在类的设置里面会显示,可以自行修改里面数值
创建变量还有子目录
//仅仅在蓝图可读
UPROPERTY(EditAnywhere, BlueprintReadOnly)
int32 BlueprintReadOnlyInt;
//在蓝图中可读可写即可以获取和设置变量
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 BlueprintReadWriteInt;
//Category目录,创建Vaule1变量(在蓝图中可以获取和设置)
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyIntValue")
int32 Value1;
//这样的写代表MySubIntValue是MyIntValue的子目录
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyIntValue|MySubIntValue")
int32 Value2;
在蓝图中也可编辑
使用meta元数据(起别名)
//meta元数据说明符
//DisPlayName别名,将Value3的名字替换成MyValue3DisplayName
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName="MyValue3DisplayName"))
int32 MyValue3;
在蓝图上搜索
EditCondition条件控制器
//只有当Controller的布尔值为true的时候才能修改isController(即Value3的值)
//EditCondition可以用于控制另一个变量
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Controller"))
bool isController;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (EditCondition = "isController"))
float Value3;
这样会使得只能当controller打勾的时候才能编辑value3
Tooltip可以使得当鼠标移动到名字上的时候显示提示
//Tooltip就是在isTrue的变量的提示
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "isControllerTrue"))
bool isTrue;
如图
笔记总结来源于:【【虚幻5】UE5C++零基础全网全流程开发从入门到进阶教程合集(持续跟新中)】https://www.bilibili.com/video/BV1Dc411f7nx?vd_source=90cb1ac44856e5e826e2bee8aa9d8a41
标签:int32,UPROPERTY,BlueprintReadWrite,EditAnywhere,C++,meta,UE,默认设置 From: https://blog.csdn.net/weixin_65376163/article/details/137545762