vault backup: 2024-10-12 17:19:45

This commit is contained in:
2024-10-12 17:19:46 +08:00
parent ff94ddca61
commit 244c0c52f6
960 changed files with 31348 additions and 10 deletions

View File

@@ -0,0 +1,64 @@
# ShowOnlyInnerProperties
- **功能描述:** 把结构属性的内部属性直接上提一个层级直接展示
- **使用位置:** UPROPERTY
- **元数据类型:** bool
- **限制类型:** FStruct属性
- **关联项:** [ShowInnerProperties](../ShowInnerProperties/ShowInnerProperties.md)
- **常用程度:** ★★★
把结构属性的内部属性直接上提一个层级直接展示,而不是像默认一样归属于一个可展开的父级结构。
## 测试代码:
```cpp
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FMyPropertyInner InnerStruct;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ShowOnlyInnerProperties))
FMyPropertyInner InnerStruct_ShowOnlyInnerProperties;
```
## 效果对比:
![Untitled](Untitled.png)
可以发现InnerStruct_ShowOnlyInnerProperties的内部属性直接就显示在对象的当前层级上而InnerStruct的属性有一个结构名称作为Category来展开。
## 原理:
在遇见FStructProperty的时候会开始判断ShowOnlyInnerProperties来决定是否要创建一个可展开的Category或者还是直接把内部属性展示出来。有了ShowOnlyInnerProperties就会直接递归迭代到其内部属性。
```cpp
void DetailLayoutHelpers::UpdateSinglePropertyMapRecursive(FPropertyNode& InNode, FName CurCategory, FComplexPropertyNode* CurObjectNode, FUpdatePropertyMapArgs& InUpdateArgs)
{
static FName ShowOnlyInners("ShowOnlyInnerProperties");
// Whether or not to push out struct properties to their own categories or show them inside an expandable struct
// This recursively applies for any nested structs that have the ShowOnlyInners metadata
const bool bPushOutStructProps = bIsStruct && !bIsCustomizedStruct && Property->HasMetaData(ShowOnlyInners);
if (bRecurseIntoChildren || LocalUpdateFavoriteSystemOnly)
{
// Built in struct properties or children of arras
UpdateSinglePropertyMapRecursive(ChildNode, CurCategory, CurObjectNode, ChildArgs);
}
}
void FObjectPropertyNode::GetCategoryProperties(const TSet<UClass*>& ClassesToConsider, const FProperty* CurrentProperty, bool bShouldShowDisableEditOnInstance, bool bShouldShowHiddenProperties,
const TSet<FName>& CategoriesFromBlueprints, TSet<FName>& CategoriesFromProperties, TArray<FName>& SortedCategories)
{
if (CurrentProperty->HasMetaData(Name_ShowOnlyInnerProperties))
{
const FStructProperty* StructProperty = CastField<const FStructProperty>(CurrentProperty);
if (StructProperty)
{
for (TFieldIterator<FProperty> It(StructProperty->Struct); It; ++It)
{
GetCategoryProperties(ClassesToConsider, *It, bShouldShowDisableEditOnInstance, bShouldShowHiddenProperties, CategoriesFromBlueprints, CategoriesFromProperties, SortedCategories);
}
}
}
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB