43 lines
1.7 KiB
Markdown
43 lines
1.7 KiB
Markdown
|
# AdvancedDisplay
|
|||
|
|
|||
|
- **功能描述:** 被折叠到高级栏下,要手动打开。一般用在不太常用的属性上面。
|
|||
|
- **元数据类型:** bool
|
|||
|
- **引擎模块:** DetailsPanel, Editor
|
|||
|
- **作用机制:** 在PropertyFlags中加入[CPF_AdvancedDisplay](../../../../Flags/EPropertyFlags/CPF_AdvancedDisplay.md)
|
|||
|
- **常用程度:★★★★★**
|
|||
|
|
|||
|
被折叠到高级栏下,要手动打开。一般用在不太常用的属性上面。
|
|||
|
|
|||
|
## 示例代码:
|
|||
|
|
|||
|
```cpp
|
|||
|
UCLASS(Blueprintable, BlueprintType)
|
|||
|
class INSIDER_API UMyProperty_Test :public UObject
|
|||
|
{
|
|||
|
//PropertyFlags: CPF_Edit | CPF_ZeroConstructor | CPF_IsPlainOldData | CPF_NoDestructor | CPF_SimpleDisplay | CPF_HasGetValueTypeHash | CPF_NativeAccessSpecifierPublic
|
|||
|
UPROPERTY(EditAnywhere, SimpleDisplay, Category = Display)
|
|||
|
int32 MyInt_SimpleDisplay = 123;
|
|||
|
|
|||
|
//PropertyFlags: CPF_Edit | CPF_ZeroConstructor | CPF_IsPlainOldData | CPF_NoDestructor | CPF_AdvancedDisplay | CPF_HasGetValueTypeHash | CPF_NativeAccessSpecifierPublic
|
|||
|
UPROPERTY(EditAnywhere, AdvancedDisplay, Category = Display)
|
|||
|
int32 MyInt_AdvancedDisplay = 123;
|
|||
|
}
|
|||
|
```
|
|||
|
|
|||
|
## 示例效果:
|
|||
|
|
|||
|

|
|||
|
|
|||
|
## 原理:
|
|||
|
|
|||
|
如果CPF_AdvancedDisplay,bAdvanced =true
|
|||
|
|
|||
|
```cpp
|
|||
|
void FPropertyNode::InitNode(const FPropertyNodeInitParams& InitParams)
|
|||
|
{
|
|||
|
// Property is advanced if it is marked advanced or the entire class is advanced and the property not marked as simple
|
|||
|
static const FName Name_AdvancedClassDisplay("AdvancedClassDisplay");
|
|||
|
bool bAdvanced = Property.IsValid() ? ( Property->HasAnyPropertyFlags(CPF_AdvancedDisplay) || ( !Property->HasAnyPropertyFlags( CPF_SimpleDisplay ) && Property->GetOwnerClass() && Property->GetOwnerClass()->GetBoolMetaData(Name_AdvancedClassDisplay) ) ) : false;
|
|||
|
|
|||
|
}
|
|||
|
```
|