Hello, is this even possible using C++ in ue4 to print all the array elements?
what is the alternative for GetEnumeratorUserFriendlyName?
I want to print all the elements located in Array, how to do this? unable to figure out how to convert UEnum type to String?
TArray<EItemType> Arr{};
for (auto& Array : Arr) //Arr is of type UEnum EItemType
{
FString Elements = TEXT("Enum Elements: ") + EnumToString(TEXT("EItemType"), static_cast<uint8>(Array));
printf("%s", *Elements); //macro
}
you can convert it using the inbuilt function GetValueAsString()
/**
* @param EnumeratorValue Enumerator Value.
*
* @return the string associated with the enumerator for the specified enum value for the enum specified by the template type.
*/
template<typename EnumType>
FORCEINLINE static FString GetValueAsString(const EnumType EnumeratorValue)
{
// For the C++ enum.
static_assert(TIsEnum<EnumType>::Value, "Should only call this with enum types");
return GetValueAsName(EnumeratorValue).ToString();
}
simply call this function under UE_LOG macro to print all the stored data to console.
so in your for loop.
for (auto& Array : Arr)
{
UE_LOG(LogTemp, Log, TEXT("The Elements in Array: %s"), *UEnum::GetValueAsString(Array));
}
hope it helps , test it and show me what results now you will have.
cheers!
thank you very much sir, this just solved the big issue , Really appreciated
the results i have now in the image, perfect as wanted, all the items are generated randomly