How to edit UPROPERTIES programatically without knowing the name of the property.

I have a project to clean up. There is a bunch of blueprints that have many children, but the values set in those blueprints are wrong. For example, there is a blueprint that represents a generic door. This blueprint is never placed on a level, but is instead used as a parent for all other doors in the game. The idea is that all the joint parameters would be set in that blueprint to be propagated to children.

The problem is, some of the properties should not have been set (for example, the mesh to be used for the door). Those should be blank. If they are blank, I can run validation checks to ensure nobody forgot to set the mesh for their door. This way, I can’t tell if they are reusing the mesh in the base on purpose, or if it’s a mistake. There are a lot of these cases, and they aren’t always as obvious as a wrong mesh.

What I want to do in both cases is update base blueprints so they are truly generic (removing the mesh). The issue with this is that child blueprints don’t store the values of their properties if they are the same as the parent, they use the value from the parent. This means that I’d break every child blueprint that uses that mesh that we started with, if I were to just remove it. What I need to do is:

  1. store the old value in the parent
  2. enumerate all the children and check if they are using that same value
  3. set the new value on the parent
  4. go through all the children that used to use the old value and set it again (since it was reset, just like in the parent blueprint)

The problem is that I’d have to write code that accesses a specific property by name. But I have to do it for every single base blueprint. This is a stupid amount of work.

What I want do to is extend the editor that, when I edit a property in the blueprint editor, it does all those steps I mentioned above. But it has to do so using some kind of reflection so I don’t have to write special code for each property, I can just find them using their name or path, take their value (I can write special implementation for every property type, no problem) and then do the same in the children blueprints and set that value.

I’m getting lost in all FProperty, FPropertyNode, FPropertyValueImpl, FProeprtyHandleObject and all the other stuff.

Is there some way where I can access the property of a blueprint using a reflection and set it the same way?

You can get all the properties of a class like this:

for (TFieldIterator PropIt(Class); PropIt; ++PropIt)
{
FProperty* Property = *PropIt;

}

To get/set the value I used this:

TSoftObjectPtr* ValuePtr = nullptr;
ValuePtr = Property->ContainerPtrToValuePtr<TSoftObjectPtr>(PropertyOuter);

*If you want to change the default values ​​for a class, then the outer of property will be CDO (UClass::GetDefaultObject())

In this case, you need to specify a specific type of property.
But there is also Set/GetValue_InContainer but I haven’t used it.