I try to declare and define the replication function for GAS attributes with C++ macro.
Macro:
#define ATTRIBUTE_REPLICATE_FUNCTION(PropertyName) \
virtual void OnRep_##PropertyName##(const FGameplayAttributeData& OldValue) \
{ \
GAMEPLAYATTRIBUTE_REPNOTIFY(UBaseAttributeSet, ##PropertyName##, OldValue) \
}
It works fine by itself. But when I add ReplicatedUsing specifier, the project does not compile.
Example:
UPROPERTY(BlueprintReadOnly, Category = "Attributes", ReplicatedUsing = OnRep_Health)
FGameplayAttributeData Health;
ATTRIBUTE_ACCESSORS(UBaseAttributeSet, Health);
ATTRIBUTE_REPLICATE_FUNCTION(Health);
compilation error:
Replication notification function 'OnRep_Health' not found
I feel like that’s because UPROPERTY is parsed by the Unreal Header Tool before C++ compiler handles the macro
Is there a way to make it work?