Is there a way to rename UPROPERTY() in C++ and get Blueprint to pickup the change?

Every once in a while I want to rename C++ member variable that has been used in a blueprint as UPROPERTY()

Is there a way to perform this automagically (something like ActiveClassRedirects or ActiveStructRedirects in DefaultEngine.ini) that wouldn’t require manually replacing old name with new on all blueprints that use it?

1 Like

well it may also mean that your design could need a maintainance.

Of course every one will, once in a while, rethink about given member or function names. Doing a renaming can mean much todo`s in other departments.

So writing code also mean to prevent the workload which comes on changes too.

In your case, you have a member variable and expose it in Blueprint.
So renaming it will cause some work in your blueprints as well.

Usually a class should hide its members and provide getter and setter for a member. So instead of exposing your member for blueprint usage (which is often not a good idea) provide UFunctions called “GetMyMember()” or “SetMyMember(Value)”.
So in the end it is not necessary to have what you desire.

maybe this helps in your coding future :wink:

kind regards

Thanks for your input, agree with everything you said :slight_smile:

Still it doesn’t answer my question – is it possible to redirect name of one member variable to another, like it is for structs and classes?

To extend on the question, is it possible to redirect a member function from one name to another without manually replacing them in blueprints?

If you look in BaseEngine.ini you’ll see a bunch of uses of K2FieldRedirects. Seems to be used in a few different ways, but the following looks like a simple renaming of a function within a class:


+K2FieldRedirects=(OldFieldName="NavigationPath.GetPathLenght",NewFieldName="NavigationPath.GetPathLength")

Not sure if that will work for properties. There’s also


+TaggedPropertyRedirects=(ClassName="NavLinkProxy",OldPropertyName="NavLinks",NewPropertyName="PointLinks")

so maybe that’s the one.

Ohh so cool!! thanks so much!

++

(Necro-apology)

Just wanted to update this for anyone coming across this thread in recent years. The unreal documentation has slightly different naming for C++ property redirects now. It’s still in the same .ini files mentioned above, but the naming is a bit different. You can even redirect a property across actors(!)

[CoreRedirects]
+PropertyRedirects=(OldName="MyOldActor.OldIntProperty",NewName="MyNewActor.NewIntProperty")
+PropertyRedirects=(OldName="MyActor.OldFloatProperty",NewName="NewFloatProperty")
4 Likes