Hi,
This might seem like a dumb question but I’ve been trying to set some metadata dynamically on 2 different attributes of the same type containing a FGameplayTag, but without success.
Given the following example, what would be the best way to achieve this?
`USTRUCT()
struct FInnerStruct
{
GENERATED_BODY()
UPROPERTY( EditAnywhere )
FGameplayTag Tag;
// Other stuff..
};
USTRUCT()
struct FMyStruct
{
GENERATED_BODY()
// I would like Foo::Tag to have meta = (Categories = “TagA”).
UPROPERTY( EditAnywhere )
TArray Foo;
// Though, I would like Bar::Tag to have meta = (Categories = “TagB”).
UPROPERTY( EditAnywhere )
TArray Bar;
};`
I’ve tried the following implementation but it obiviously affects the whole FInnerStruct metadata, and not just the attribute’s metadata.
`bool FMyStruct::Serialize( FArchive& )
{
static const FName NAME_Categories = TEXT( “Categories” );
{
// Attempt to modify FMyStruct::Foo.Tag’s metadata.
FArrayProperty * arrayProperty = FindFieldChecked( StaticStruct(), GET_MEMBER_NAME_CHECKED( FMyStruct, Foo ) );
if ( FStructProperty * inner = CastField( arrayProperty->Inner ) )
{
FProperty * prop = FindFieldChecked( inner->Struct, GET_MEMBER_NAME_CHECKED( FInnerStruct, Tag ) )
prop->SetMetaData( NAME_Categories, TEXT(“TagA”) );
}
}
{
// Attempt to modify FMyStruct::Bar.Tag’s metadata.
FArrayProperty * arrayProperty = FindFieldChecked( StaticStruct(), GET_MEMBER_NAME_CHECKED( FMyStruct, Bar ) );
if ( FStructProperty * inner = CastField( arrayProperty->Inner ) )
{
FProperty * prop = FindFieldChecked( inner->Struct, GET_MEMBER_NAME_CHECKED( FInnerStruct, Tag ) )
prop->SetMetaData( NAME_Categories, TEXT(“TagB”) );
}
}
return false;
}`
Thank you for your help,
- Cédric