Alexa.Ki
(Alendromeda.ki)
August 10, 2022, 11:34pm
1
Hi, how to log a member from array of type FName
.
TArray<FIDStruct> IDStruct_Arr{}
FName ID; //member of the IDStruct
for (auto& Array : IDStruct_Arr)
{
//How to Log the Array.ID here?
}
an example of logging actor’s name.
`UE_LOG(LogTemp, Warning, TEXT("The Actor's name is %s"), *YourActor->GetName());`
Snippet from code logging input to OpenLevel() which requires an FName:
FName mapName;
LOG("ProcessLoadMapRequest() - load map: %s ...", *mapName.ToString());
UGameplayStatics::OpenLevel(GetWorld(), mapName);
LOG("ProcessLoadMapRequest() - load map: %s complete.", *mapName.ToString());
1 Like
c0r37py
(c0r37py::)
August 11, 2022, 12:14am
3
if your variable ID is declared in the IDStruct
you can access it and convert directly
UE_LOG(LogTemp, Warning, TEXT("Val is: %s"), *Array.ID.ToString());
hope it helps
cheers!
2 Likes
Alexa.Ki
(Alendromeda.ki)
August 11, 2022, 12:18am
4
both solutions working perfectly, but I don’t want to convert to string, I want to log the FName directly if possible.
Thank you
Not aware of any other way to log fnames. Here’s the string handling doc:
String Handling | Unreal Engine Documentation
Also, not sure about anyone else, but we purged all FNames from code due to encountering weird issues with them in release / cooked builds. Also they are harder to log. If a base Unreal call requires it then we convert where needed.
1 Like
c0r37py
(c0r37py::)
August 11, 2022, 12:41am
6
FName is actually a string in some cases.
ex: if you wan to convert FText to FName
FText myText;
FName name = FName(*myText.ToString());
other types of quick conversion:
// FText: FString to FText
FString Str;
FText text = FText::FromString(Str);
// FText: FName to FText
FName name;
FText text = FText::FromName(name);
// FString: FText to FString
FText text;
FString str = text.ToString();
// FString: FName to FString
FName name;
FString str = name.ToString();
// FName: FString to FName
FString Str;
FName name = FName(*Str);
and follow the documentation @Shmoopy1701 shared.
hope it helps
cheers
1 Like
Alexa.Ki
(Alendromeda.ki)
August 11, 2022, 12:43am
7
thanks very much for @Shmoopy1701 @c0r37py
1 Like
Alexa.Ki
(Alendromeda.ki)
August 11, 2022, 12:50am
9
1 Like