Ability to create FName from FString, or FGuid returning FName

It would be nice if there was possibility to create FName from FString.
Or if FGuid returned FName, because right now it only return FString.

Or if there would be some class that would generate random unique FNames.

It would be nice, for creating unique handles for objects, where they would be needed. I wanted to use FGuid, because GUIDs are guarantee to be world unique, but searching trough string is not most efficient thing.

Haven’t tried it, but would this constructor work for you?

Something like


 FName name(NAME_NetworkGUID, *guid.ToString());

FNames can be created from TCHAR and FString can be converted to TCHAR using the * operator. The syntax you want is:



FString TheString;
FName TheName(*TheString);


Objects have unique names by default, I’m not really clear on what the use case you’d want to be converting a FGuid to an FName.

Depending on your needs, MakeUniqueObjectName may be an interesting function to you.

I have different actors attached to other actor. Those actors should exist as long as effect, which affecting actor (like damage over time).

When effect ends, also associated effects should be destroyed. I figured out easiest way, will to to give Effect and Actors unique handle. When effects end, I would just search attached actors by handle and destroy them.

I didn’t wanted to use ints, because I don’t know any reliable way to generate unique numbers.

Anyway, thanks!. I didn’t now you can conver FString to TCHAR, this way.

You can just use the object address as a unique handle (the pointer to the UObject / AActor), if this is only for the duration of a game and doesn’t need to be persisted to disk.

Cheers,
Michael Noland