How to change visible variable name in editor

Hi.

What I’m trying to achieve is to have variable in cpp named differently than variable in editor.
For example:

In cpp I want to have it named SuperProjectilePlayerHitted .

And in editor I want to have it named ProjectileFX .

I tried use meta = (Displayname = “name”) like this:

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (DisplayName = "ProjectileFX"))
    	UParticleSystemComponent* SuperProjectilePlayerHitted;

SuperProjectilePlayerHitted = ObjectInitializer.CreateDefaultSubobject<UParticleSystemComponent>(this, TEXT("ProjectileFX"));

But without luck. Result looks like this:

131358-variable_name.png

Is there way how to show different name in editor than variable from cpp ? Sometimes I need create self-describing names in cpp, but I don’t need long names in editor.

Thanks a lot.

It doesn’t seem that there is an easy way to do this cleanly. The relevant code in Editor/Kismet/.../SSCSEditor.(cpp|h) does not seem to check for metadata (for native classes, at least).

However, what you can do is the following, slightly hacky, workaround:

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
	UParticleSystemComponent* ProjectileFX;
	UParticleSystemComponent*& MyProjectileHitPlayerParticleSystem = ProjectileFX;

Then the component appears as ProjectileFX in the editor, but you can use the long name to access it from C++. The disadvantage is, of course, that you now have two names in your C++ code that mean the same thing.

A better solution might be to use the short name for the variable, but to make it private and provide accessors with the longer names that you want to have in your C++ code.

Yeah, this trick works fine I was just curious how to use
meta = (DisplayName = “visible name”). What is the purpose of this meta property anyway ?

I think you have the right idea how this is supposed to work: It changes the name displayed in the editor from the one you use in the code. It’s just that UE4 is pretty inconsistent where it uses this metadata and where it doesn’t. For example, I have defined the following enumeration:

UENUM(BlueprintType, Meta = (DisplayName = "B4 Truth Value Enum", ToolTip = "An enumerated value in Belnap Logic (B4). Typically not used on its own but rather as value member of an FB4Value struct."))
enum class EB4Value : uint8
{
	EUnknown		UMETA(DisplayName = "Unknown"),
	EFalse			UMETA(DisplayName = "False"),
	EInconsistent	UMETA(DisplayName = "Inconsistent"),
	ETrue			UMETA(DisplayName = "True")
};
USTRUCT(BlueprintType, Meta = (DisplayName = "B4 Truth Value"))
struct FB4Value
{ ... /* EB4Value member and some methods */ }

I cannot use True and False as enumerators, since they confuse UHT, so for consistency I’ve used the prefix E on all of them. By specifying a display name, I can show the nicer name without the prefix in the editor:

However, you’ll note that the header of the node does not make use of the DisplayName meta data on FB4Value. If you define a variable for a type with DisplayName metadata specifier, however, it will be used:

In my opinion, specifying the display name is useful in some situations but I’ve come to use it less and less over time and generally try to find names that work reasonably well both in C++ code and in the editor.

Thanks for your insights. I was looking for a way how to make naming easy for level designers. In result, I don’t use DisplayName since it’s not consistent. So I edit my variable names to short names, which still make sense in cpp.