Here I have a TMap:
// .h
private:
static TMap<FGameplayTag, FGameplayTag> DamageToResilienceTypeTags;
//.cpp
TMap<FGameplayTag, FGameplayTag> UAuraBlueprintFunctionLibrary::DamageToResilienceTypeTags = TMap<FGameplayTag, FGameplayTag>
{
{AuraGameplayTags::Damage_Fire, AuraGameplayTags::Attribute_Secondary_ResilienceFire},
{AuraGameplayTags::Damage_Lightning, AuraGameplayTags::Attribute_Secondary_ResilienceLightning},
{AuraGameplayTags::Damage_Arcane, AuraGameplayTags::Attribute_Secondary_ResilienceArcane},
{AuraGameplayTags::Damage_Physical, AuraGameplayTags::Attribute_Secondary_ResiliencePhysical},
};
Then, I have a Getter function for it:
//.h
UFUNCTION(BlueprintCallable)
static TMap<FGameplayTag, FGameplayTag> GetAuraDamageToResilienceTypeTags()
//.cpp
TMap<FGameplayTag, FGameplayTag> UAuraBlueprintFunctionLibrary::GetAuraDamageToResilienceTypeTags()
{
return DamageToResilienceTypeTags;
}
At runtime, this Getter function get undefine results like this:
Question:
1. Why is that, any problem about my code?
2. When I modify Getter function(use reference return), problem solved, why is that?
//.h
UFUNCTION(BlueprintCallable)
static TMap<FGameplayTag, FGameplayTag>& GetAuraDamageToResilienceTypeTags();
//.cpp
TMap<FGameplayTag, FGameplayTag>& UAuraBlueprintFunctionLibrary::GetAuraDamageToResilienceTypeTags()
{
return DamageToResilienceTypeTags;
}