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,73 @@
# HideFromModifiers
- **功能描述:** 指定AttributeSet下的某属性不出现在GameplayEffect下的Modifiers的Attribute选择里。
- **使用位置:** UPROPERTY
- **引擎模块:** GAS
- **元数据类型:** bool
- **限制类型:** UAttributeSet下的属性
- **关联项:** [HideInDetailsView](../HideInDetailsView/HideInDetailsView.md)
- **常用程度:** ★★★
指定AttributeSet下的某属性不出现在GameplayEffect下的Modifiers的Attribute选择里。
## 测试代码:
```cpp
UCLASS()
class UMyAttributeSet : public UAttributeSet
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Core")
float HP = 100.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Core", meta = (HideInDetailsView))
float HP_HideInDetailsView = 100.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Core", meta = (HideFromModifiers))
float HP_HideFromModifiers = 100.f;
};
UCLASS()
class UMyAttributeSetTest : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "GAS")
FGameplayAttribute MyAttribute;
};
```
## 测试结果:
在蓝图中创建一个GameplayEffect然后观察其Modifiers下的Attribute选择。
发现HP_HideFromModifiers 可以出现在正常的FGameplayAttribute 选项卡中但不能出现在Modifiers下的Attribute选项卡里。这就是这里的作用。
![Untitled](Untitled.png)
## 原理:
在FGameplayModifierInfo的Attribute属性上有FilterMetaTag的元数据然后取出其里面的值最终还是传到GetAllAttributeProperties作为FilterMetaStr来过滤。因此属性上出现HideFromModifiers就不能出现。
```cpp
USTRUCT(BlueprintType)
struct GAMEPLAYABILITIES_API FGameplayModifierInfo
{
GENERATED_USTRUCT_BODY()
/** The Attribute we modify or the GE we modify modifies. */
UPROPERTY(EditDefaultsOnly, Category=GameplayModifier, meta=(FilterMetaTag="HideFromModifiers"))
FGameplayAttribute Attribute;
};
void FAttributePropertyDetails::CustomizeHeader( TSharedRef<IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils )
{
const FString& FilterMetaStr = StructPropertyHandle->GetProperty()->GetMetaData(TEXT("FilterMetaTag"));
SNew(SGameplayAttributeWidget)
.OnAttributeChanged(this, &FAttributePropertyDetails::OnAttributeChanged)
.DefaultProperty(PropertyValue)
.FilterMetaData(FilterMetaStr)
}
void FGameplayAttribute::GetAllAttributeProperties(TArray<FProperty*>& OutProperties, FString FilterMetaStr, bool UseEditorOnlyData)
{}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

View File

@@ -0,0 +1,96 @@
# HideInDetailsView
- **功能描述:** 把该UAttributeSet子类里的属性隐藏在FGameplayAttribute的选项列表里。
- **使用位置:** UCLASS, UPROPERTY
- **引擎模块:** GAS
- **元数据类型:** bool
- **限制类型:** UAttributeSet
- **关联项:** [HideFromModifiers](../HideFromModifiers/HideFromModifiers.md), [SystemGameplayAttribute](../SystemGameplayAttribute/SystemGameplayAttribute.md)
- **常用程度:** ★★★
把该UAttributeSet子类里的属性隐藏在FGameplayAttribute的选项列表里。
可用在UCLASS上隐藏掉整个类里的所有属性也可以用在某个特定属性上只隐藏该属性。
在源码里用到的例子是UAbilitySystemTestAttributeSet因为其就是一个专门用来测试的AS因此希望不影响正常的选项列表。
## 测试代码:
```cpp
UCLASS()
class UMyAttributeSet : public UAttributeSet
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Core")
float HP = 100.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Core", meta = (HideInDetailsView))
float HP_HideInDetailsView = 100.f;
};
UCLASS(meta = (HideInDetailsView))
class UMyAttributeSet_Hide : public UAttributeSet
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Core")
float HP = 100.f;
};
UCLASS()
class UMyAttributeSetTest : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "GAS")
FGameplayAttribute MyAttribute;
};
```
## 测试效果:
可见只能选到UMyAttributeSet.HP属性无法选择到UMyAttributeSet_Hide里的选项。
![Untitled](Untitled.png)
## 原理:
```cpp
PropertyModule.RegisterCustomPropertyTypeLayout( "GameplayAttribute", FOnGetPropertyTypeCustomizationInstance::CreateStatic( &FAttributePropertyDetails::MakeInstance ) );
void FGameplayAttribute::GetAllAttributeProperties(TArray<FProperty*>& OutProperties, FString FilterMetaStr, bool UseEditorOnlyData)
{
for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
{
if (UseEditorOnlyData)
{
#if WITH_EDITOR
// Allow entire classes to be filtered globally
if (Class->HasMetaData(TEXT("HideInDetailsView")))
{
continue;
}
#endif
}
for (TFieldIterator<FProperty> PropertyIt(Class, EFieldIteratorFlags::ExcludeSuper); PropertyIt; ++PropertyIt)
{
FProperty* Property = *PropertyIt;
if (UseEditorOnlyData)
{
// Allow properties to be filtered globally (never show up)
if (Property->HasMetaData(TEXT("HideInDetailsView")))
{
continue;
}
#endif
}
OutProperties.Add(Property);
}
}
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,85 @@
# SystemGameplayAttribute
- **功能描述:** 把UAbilitySystemComponent子类里面的属性暴露到FGameplayAttribute 选项框里。
- **使用位置:** UPROPERTY
- **引擎模块:** GAS
- **元数据类型:** bool
- **限制类型:** UAbilitySystemComponent子类里面的属性
- **关联项:** [HideInDetailsView](../HideInDetailsView/HideInDetailsView.md)
- **常用程度:** ★★★
把UAbilitySystemComponent子类里面的属性暴露到FGameplayAttribute 选项框里。
## 源码例子:
```cpp
UCLASS(ClassGroup=AbilitySystem, hidecategories=(Object,LOD,Lighting,Transform,Sockets,TextureStreaming), editinlinenew, meta=(BlueprintSpawnableComponent))
class GAMEPLAYABILITIES_API UAbilitySystemComponent : public UGameplayTasksComponent, public IGameplayTagAssetInterface, public IAbilitySystemReplicationProxyInterface
{
/** Internal Attribute that modifies the duration of gameplay effects created by this component */
UPROPERTY(meta=(SystemGameplayAttribute="true"))
float OutgoingDuration;
/** Internal Attribute that modifies the duration of gameplay effects applied to this component */
UPROPERTY(meta = (SystemGameplayAttribute = "true"))
float IncomingDuration;
}
```
## 测试代码:
```cpp
UCLASS(Blueprintable, BlueprintType)
class UMyAbilitySystemComponent : public UAbilitySystemComponent
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "GAS")
float MyFloat;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "GAS", meta = (SystemGameplayAttribute))
float MyFloat_System;
};
UCLASS()
class UMyAttributeSetTest : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "GAS")
FGameplayAttribute MyAttribute;
};
```
## 测试效果:
可见MyFloat_System可以暴露到选项列表里去。
![Untitled](Untitled.png)
## 原理:
也是在GetAllAttributeProperties判断属性上的SystemGameplayAttribute标记。
```cpp
void FGameplayAttribute::GetAllAttributeProperties(TArray<FProperty*>& OutProperties, FString FilterMetaStr, bool UseEditorOnlyData)
{
// UAbilitySystemComponent can add 'system' attributes
if (Class->IsChildOf(UAbilitySystemComponent::StaticClass()) && !Class->ClassGeneratedBy)
{
for (TFieldIterator<FProperty> PropertyIt(Class, EFieldIteratorFlags::ExcludeSuper); PropertyIt; ++PropertyIt)
{
FProperty* Property = *PropertyIt;
// SystemAttributes have to be explicitly tagged
if (Property->HasMetaData(TEXT("SystemGameplayAttribute")) == false)
{
continue;
}
OutProperties.Add(Property);
}
}
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB