Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to change visible variable name in editor


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: alt text

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.

Product Version: UE 4.15
more ▼

asked Mar 23 '17 at 10:31 AM in C++ Programming

avatar image

244 15 19 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Mar 24 '17 at 04:12 AM

avatar image

Matthias Hölzl
416 13 6 19

avatar image hubacek.jakub Mar 24 '17 at 07:12 AM

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 ?

avatar image Matthias Hölzl Mar 24 '17 at 08:16 PM

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:

alt text

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:

alt text

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.

b4-02.png (57.0 kB)
b4-01.png (95.0 kB)
avatar image hubacek.jakub Mar 25 '17 at 10:59 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question