Hi!
In our project we’d like to use the “m_” prefix for member variables internally in our C++ code but when they’re exposed to Blueprint, that would be confusing to non-programmers. Searching a bit, I’ve found the DisplayName property specifier which sounds like exactly what we need: “Sets the display name for the property in the editor.”
So I declared my variable like this:
UPROPERTY( BlueprintReadOnly, Config, Category = CombatStats, DisplayName = "Critical Hit Chance" )
float m_criticalHitChance;
In the editor, it shows up as m_criticalHitChance.
Since DisplayName is listed under Valid Meta Properties, I then tried the following:
UPROPERTY( BlueprintReadOnly, Config, Category = CombatStats, meta=(DisplayName = "Critical Hit Chance") )
float m_criticalHitChance;
But this resulted in the variable not even turning up in the editor at all. Worse, if the variable was previously referenced in a Blueprint, the Blueprint will throw a compiler error and the following error message was printed to the log:
LogBlueprint:Warning: [CombatComponent_BP] CreatePinForVariable: ‘m_criticalHitChance’ variable not found. Base class was probably changed.
LogBlueprint:Warning: [compiler CombatComponent_BP] Warning Could not find a variable named “m_criticalHitChance” in ‘CombatComponent_BP_C’. Make sure ‘CombatComponent_BP_C’ has been compiled for Get m_criticalHitChance
Strangely, I just tried this again and can’t reproduce the second part. The variable always turns up but it’s still displayed as m_criticalHitChance.
So how do you change the editor display name of a variable declared in C++?