C++ Set Component Name for Blueprint?

Hey everyone,

tl;dr:
How do I set the name of my component in C++ so it is displayed correctly in derived blueprints?

Long version:
I’m extending an AActor class which I’ll call TestClass for this example and then create a blueprint with TestClass as the base.

Example:
In the header file of TestClass:

UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "TestClass", DisplayName = "MyMeshDisplay")
UStaticMeshComponent* mMesh;

In the constructor of TestClass:

mMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MyMeshName"));
mMesh->SetMobility(EComponentMobility::Static);
mMesh->SetCastShadow(false);
Mesh->SetCollisionProfileName("BlockAll");
mMesh->SetupAttachment(RootComponent);

And then when i create a blueprint based on this class, the component is listed as mMesh in the component view.
I would expect the component to either be named MyMeshDisplay or MyMeshName but neither is true.

Using Rename in the OnConstruction method causes the name to be correct for instances of the blueprints. Not for the default archetype however.

Hey Chartas-

The DisplayName affects the name shown in the details panel as well as the name shown when searching in the right click menu. The name shown in the hierarchy list is controlled by the name of the pointer itself. To change the name in the hierarchy list, the best option would be to change mMesh to whatever name you want to see in the editor. For this reason, I find it easiest to give the pointer itself the same name as the display name I want in the editor.

Cheers

So it’s either have clean names for the blueprints or have consistent and readable c++ code?

I mean functions like Rename do seem to have some kind of effect, at least on instances. Is the naming generation part of the header tool or is there a function where one might change this behaviour?

I am not sure these have to be viewed independently. For example, “WeaponMeshComp” could be the name used in code as well as the blueprint hierarchy for a static mesh that is meant to represent a character’s weapon. I have, however, entered feature request UE-33566 to possibly have this functionality included moving forward.

Thank you for the help. =)