Let’s say that you want to name member variables with a prefix, like mName or m_Name. By default, Unreal will convert both of these to “M Name”. Is there any way (short of modifying engine code) to change the way this works so that it will still end up showing it as “Name”?
To be clear, I’m talking about universal solutions i.e. using the DisplayName meta tag is not the sort of thing I’m looking for.
There is not, that I’m aware of, outside of the two solutions you came up with. Well, there might be a third possible solution, writing a plugin that overrides and/or extends the engine’s handling of that, however I don’t have the slightest idea where the code would be that handles that, to see if it’s something that could be done.
For what it’s worth, prefixing things like that is generally considered a bad practice, and I think the main reason Unreal continues to do it with booleans, is because of how easy it is in C++ to get bools and ints confused with each other.
I definitely disagree on that being a bad practice. Not sure what companies you’ve worked for but Unreal is the first engine I’ve worked on that doesn’t use prefixes to denote scope. The fact that literally everything in the engine is both PascalCase and has no prefix is wild to me.
I was frustrated that there was nowhere online with an answer to this so I decided to find where Unreal creates its display names. It already removes “b” prefixes on bools in Engine\Source\Runtime\Core\Private\UObject\UnrealNames.cpp Line 2504, so you can just modify this code so that it ignores other prefixes like “m”. This does mean changing Engine code, so it will require that you build from Source: Downloading Unreal Engine Source Code | Unreal Engine 5.4 Documentation | Epic Developer Community
Here’s my modified code:
// Skip the character if using any combination of m, b and _ before the first Uppercase character
// For example, a bool could be m_bIsOn, so the editor should show IsOn
if (OutDisplayName.Len() == 0 && (bIsBool && ch == 'b' || ch == 'm' || bIsUnderscore))
{
continue;
}
It looks like in Unreal 5.2 and beyond (maybe even earlier) there is an option in Edit → Editor Preferences → User Interface called “Show Friendly Variable Names”. Turning this option off will stop the variable name processing that occurs and display your variable names exactly as they were written. It’s not quite what you were asking, but it’s the closest thing that Unreal has right now if you don’t want to modify the engine code.
Also, please don’t forget to mark this as solved so that future users can find the answer easily. Google links to this forum post as one of the higher up links for this topic.