CreateDefaultSubobject name seems to not do anything

So I was looking at the documentation for CreateDefaultSuboject FObjectInitializer::CreateDefaultSubobject | Unreal Engine Documentation

And the description for the SubobjectName property is pretty loose: “name of the new component”.

Ok… does this mean the string I pass into the function is what the editor will display for the component in the details tab?

I made a test, like so:

class VRTEST2_API AMyPawn : public APawn

	// Sets default values for this pawn's properties

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

		UBoxComponent* aBox;


 	// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	aBox = CreateDefaultSubobject<UBoxComponent>(TEXT("TheBox"));

And was expecting the editor to show this pawn’s component as “TheBox”. But instead it shows the member declaration identifier (aBox):

So what’s the point of this parameter? is it just for search purposes within code? Like, assigning a tag to the object?

I’m a beginner and I’ve been playing around with it for a bit and this is what I observed. The reason it uses the variable name (aBox) rather than whatever you put inside TEXT(“TheBox”) is because you have UPROPERTY(EditAnywhere) above UBoxComponent* aBox;. If you want the text inside TEXT() to show up, comment out the UPROPERTY line and that’s it.

Marking it as the right answer because this is the closest we’ll get without looking at the source code (which I do not have time to do now). But from your observation, what I’m thinking now is this: The text is an argument to the object constructor. It probably sets a name property inside it. If you don’t make it a UPROPERTY the editor probably asks the object for name and uses that. if instead you make a UPROPERTY, you are really opting in to the whole BP reflection system, which happens at compile time and results in the ‘generated’ files. In this case, the reflection system uses the property identifier (the name of the variable) as the name of the object.