F5.UPROPERTY
大约 3 分钟
UPROPERTY定义
//声明一个变量
int32 MyInt;
//定义一个变量
int32 MyInt = 0;
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyTest.generated.h"
UCLASS()
class EXORCIST_API AMyTest : public AActor
{
GENERATED_BODY()
public:
UPROPERTY(VisibleAnywhere,BlueprintReadOnly)
int32 VisibleAnywhereNumber;
UPROPERTY(VisibleDefaultsOnly,BlueprintReadOnly)
int32 VisibleDefaultsOnly;
UPROPERTY(VisibleInstanceOnly,BlueprintReadOnly)
int32 VisibleInstanceOnly;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
int32 EditAnywhereNumber;
UPROPERTY(EditDefaultsOnly)
int32 EditDefaultsOnlyNumber;
};
属性说明符
VisibleAnywhere
&BlueprintReadOnly
该属性在所有属性窗口中可见,但不可编辑,需配合BlueprintReadOnly。
UPROPERTY(VisibleAnywhere,BlueprintReadOnly)
int32 VisibleAnywhereNumber;
VisibleDefaultsOnly
& BlueprintReadOnly
该属性在所有属性窗口中可见,但只能在类的默认属性面板中编辑。在蓝图中是只读的。
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly)
int32 VisibleDefaultsOnlyNumber;
VisibleInstanceOnly
& BlueprintReadOnly
该属性在所有属性窗口中可见,但只能在每个实例的属性面板中编辑。在蓝图中是只读的。
UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly)
int32 VisibleInstanceOnlyNumber;
EditAnywhere
&BlueprintReadWrite
该属性在所有属性窗口中可见且可编辑。在蓝图中可以读写。
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 EditAnywhereNumber;
EditDefaultsOnly
该属性在所有属性窗口中可见,但只能在类的默认属性面板中编辑。在蓝图中可以读写。
UPROPERTY(EditDefaultsOnly)
int32 EditDefaultsOnlyNumber;
Category
Category|分组
UPROPERTY(EditAnywhere, Category="分组")
int32 Category;
UPROPERTY(EditAnywhere, Category="分组|子标签")
int32 Child;
ShowOnlyInnerProperties
内联显示属性
USTRUCT()
struct FCat
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly)
FString Name;
UPROPERTY(EditDefaultsOnly)
int32 Age;
UPROPERTY(EditDefaultsOnly)
FLinearColor Color;
};
//ShowOnlyInnerProperties
UPROPERTY(EditAnywhere, Category="ShowOnlyInnerProperties")
FCat NormalProperties;//正常显示
UPROPERTY(EditAnywhere, Category="ShowOnlyInnerProperties", meta=(ShowOnlyInnerProperties))
FCat ShowOnlyInnerProperties;//内联显示
Tooltip
提示文本
UPROPERTY(EditAnywhere, meta=(ToolTip="提示文本"))
int32 Tooltip;
DisplayName
显示名称
UPROPERTY(EditAnywhere, meta=(DisplayName="Display Font"))
FSoftObjectPath DisplayName;
AdvancedDisplay
高级显示,属性隐藏在下拉菜单中
UPROPERTY(EditAnywhere, Category="AdvancedDisplay")
bool NormalDisplay1;
UPROPERTY(EditAnywhere, Category="AdvancedDisplay")
bool NormalDisplay2;
UPROPERTY(EditAnywhere, Category="AdvancedDisplay", AdvancedDisplay)
bool AdvancedDisplay;
InlineEditConditionToggle
内联联动
UPROPERTY(EditAnywhere, meta=(InlineEditConditionToggle))
bool bCanFly;
UPROPERTY(EditAnywhere, meta=(EditCondition="bCanFly", Units="s"))
float InlineEditConditionToggle;