UPROPERTY()
在蓝图中暴露的C++类成员的可见性和可编辑性。
UE4源代码中的文档(另请参见UE4 wiki,UE4文档)对可编辑性的说明如下:
- 对于
VisibleAnywhere
,VisibleInstanceOnly
,VisibleDefaultsOnly
: - 对于
EditAnywhere
,EditInstanceOnly
,EditDefaultsOnly
: 对于
BlueprintReadOnly
:... 可以被蓝图读取,但无法修改。
和
BlueprintReadWrite
:... 可以在蓝图中读取或写入。
... 无法进行编辑。
... 可以进行编辑。
问题:
Since the
Visible*
specifiers already restrict the usage to read only in Blueprints, why it is used in conjunction withBlueprintReadOnly
? Isn't the second specifier superfluous? Example:UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly) UMyActorComponent* MyActorComponent;
Even more confusing is the usage of
Edit*
specifiers, which allow read and write in Blueprint, together withBlueprintReadOnly
which restricts to read only in Blueprint. Aren't both specifiers opposing each other? Example:UPROPERTY(EditAnywhere, BlueprintReadOnly) UMyActorComponent* MyActorComponent;
- Are the
Visible*
/Edit*
specifiers valid in a different context than theBlueprintRead*
specifiers? (the question is not aboutInstanceOnly
(property windows for instances),DefaultsOnly
(property windows for archetypes) andAnywhere
(instances & archetypes))