Having C++ inherited components be editable in blueprints, when the component is declared in another component, and not in the actor itself

Hello,

I’m having some trouble getting C++ inherited components exposed to blueprints where they are editable in the details tab.

Through searching, I have learned how to expose inherited components to blueprints and have them be editable. However, I’m having problems only when the component is declared in another component, and not declared in the actor itself.

Here’s the scenario:

  1. I create a C++ actor AFooActor, inherited from AActor.
  2. I create a C++ component UBarSceneComponent, inherited from USceneComponent.
  3. In AFooActor, I declare a USkeletalMeshComponent FooMesh, and a UBarSceneComponent BarScene.
  4. In UBarSceneComponent, I declare another USkeletalMeshComponent BarMesh.
  5. In both AFooActor and UBarSceneComponent’s constructors, I instantiate the above components using CreateDefaultSubobject.
  6. Finally, I create a blueprint BP_Foo, inherited from AFooActor.

In this case, when I open BP_Foo in the blueprint editor, I would expect FooMesh, BarScene, and BarMesh all to be exposed and editable with the details tab. However, only FooMesh and BarScene, which are declared directly in the actor, are editable. BarMesh, which is declared in UBarSceneComponent and not in the actor, is not editable.

Below are screenshots and code to illustrate.

AFooActor

// Header
#pragma once
    
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FooActor.generated.h"
    
UCLASS()
class MYAPPLICATION_API AFooActor : public AActor
{
	GENERATED_BODY()

public:
	AFooActor();
	AFooActor(const FObjectInitializer& ObjectInitializer);

public:
	// Declare FooMesh
	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Foo")
	class USkeletalMeshComponent* FooMesh;

	// Declare BarScene
	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Foo")
	class UBarSceneComponent* BarScene;
};

// Constructor
AFooActor::AFooActor(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	// Works; FooMesh is visible in the blueprint, and the details panel is fully exposed and editable
	this->FooMesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("FooMesh"));

	this->BarScene = ObjectInitializer.CreateDefaultSubobject<UBarSceneComponent>(this, TEXT("BarScene"));
}

UBarSceneComponent

// Header
#pragma once

#include "CoreMinimal.h"
#include "Components/SceneComponent.h"
#include "BarSceneComponent.generated.h"

UCLASS(ClassGroup = (FooBar), meta = (BlueprintSpawnableComponent))
class MYAPPLICATION_API UBarSceneComponent : public USceneComponent
{
	GENERATED_BODY()

public:
	UBarSceneComponent();
	UBarSceneComponent(const FObjectInitializer& ObjectInitializer);

public:
	// Declare BarMesh
	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Bar")
	class USkeletalMeshComponent* BarMesh;
};

// Constructor
UBarSceneComponent::UBarSceneComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	// NOT editable; I can see BarMesh in the blueprint, but the details panel is empty and cannot be edited
	this->BarMesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("BarMesh"));
}

Screenshots of the BP_Foo blueprint are attached. FooMesh and BarScene are exposed and editable. BarMesh is exposed, but not editable.

So my question is, what is the best way to have components declared within components be editable in the blueprint just like those declared in the actor? Is what I’m trying to do possible? I suspect I have some fiddling to do with the UPROPERTY fields, but so far I haven’t found a solution.

Any help is appreciated. Thanks in advance.

Looking at my setup again, I just realized that the details for BarMesh seem to be included in the details panel for the BarScene component (as shown in the attached ss-barscene.png). It’s just not in the details panel for BarMesh, where I would have expected.

This certainly addresses my problem, and I feel a bit silly for not noticing this off the bat, but I suppose this is the intended behavior?

How did you even get foomesh to be editable? I thought inherited components were completely uneditable?
EDIT: I see it’s in the declaration macro. This was really informative, thanks.