Download

Changing a UPROPERTY from FName to FString

Hey,

We have an FName UPROPERTY in a C++ class and want to change the type to FString, is it possible to do this without losing all the preexisting data entry ?

Cheers,
Steve.

In a round about way.

  1. Mark the FName field as Deprecated.
  2. Add some code in OnLoad that checks the new field if it’s empty and copies over the old field.


void UMyObject::OnLoad()
{
   if (MyFStringField.IsEmpty())
   {
       MyFStringField = MyFNameField.ToString();
   }
}


  1. Save all assets and remove the old field, and the on load code.

Or just try it out and if it doesn’t work rollback the changes in your version control :slight_smile: