I have an FText variable marked with AssetRegistrySearchable, which works fine, only that when I get it’s value by “Data.TagsAndValues.Find”, it gives back an FString, which is not in a readable format.
return value is this:
“NSLOCTEXT(”", “”, “Deathmatch”)"
While I understand that this is the format I use when I make an FText in C++ code, my question is, how can I make FText from this format? Which uses the right localisation.
After searching in the source code I found the following methods in FAssetData which solved the problem:
/** Try and get the value associated with the given tag as a type converted value */
template <typename ValueType>
bool GetTagValue(const FName InTagName, ValueType& OutTagValue) const;
/** Try and get the value associated with the given tag as a type converted value, or an empty value if it doesn't exist */
template <typename ValueType>
ValueType GetTagValueRef(const FName InTagName) const;
These methods also offer some nice advantages over getting the values by hand:
Common values are parsed to the correct type automatically. I also think FText values are automatically localized, but haven’t tested this out yet.
There’s no need to check if a tag is in the data by using TagsAndValues.Find as the methods already take care of that.
Hope this will be useful to anyone who ends up here looking for a solution to the same problem (like I did).
I’ve already done a workaround, I don’t even remember why did I want this, so I can’t test it out, but I believe you, so will mark this as a solution. Thank you!