Custom component not visible in editor

Hello,

I have a class that inherits from UStaticMeshComponent and serves as a template. I also have two other classes Shield and Reflect, that inherit from this custom class. I want to be able to dynamically add those classes to my character and edit them directly in the editor just like you can edit regular components.

So far I’ve managed to choose which component to spawn (either shield or reflect) and check that it is correctly spawned. However, I’m still not able to see the component in the components tab so that I can edit it directly.

Here’s what I have inside my character’s .h file

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Ability)
TSubclassOf<UTPSComponent> SpecialAbilityClass;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Special, meta = (AllowPrivateAccess = "true"))
class UTPSComponent* SpecialAbility;

And here’s the inside of the .cpp

void ACPP_TPSCharacter::PostInitializeComponents()
{
	Super::PostInitializeComponents();
	if (SpecialAbilityClass)
	{
		SpecialAbility = ConstructObject<UTPSComponent>(SpecialAbilityClass, this, TEXT("Special Skill"));
		SpecialAbility->AttachTo(RootComponent);
		SpecialAbility->RegisterComponent();
	}
}

My components are BlueprintSpawnable, and if I click the Add Component button they will appear in the list and be spawned properly. However I’m unable to see the one that I already have inside my character. The only thread that I was able to find was this one. I added the OnRegister() override but I’m still unable to see my component.

shameless bump

Swiftle,

I saw this issue earlier, and found your post.
I noticed that I was unable to see custom components inside my actor either. However, if I created an instance inside the constructor for the actor, they appeared.

So one thing you may be able to try is to do something like this:

UTPSComponent::Init(Params...)
{
    // Perform initialization that would normally happen in the constructor.
}

AMyActor::AMyActor()
{
    // ... Other initialization stuffs.
   SpecialAbility = CreateDefaultSubobject<UTPSComponent>(TEXT("SpecialSkill"));

    // ... More initializations stuffs.
}

AMyActor::PostInitialize()
{
    if (SpecialAbilityClass)
    {
        SpecialAbility->Init(SpecialAbilityClass, this);
        SpecialAbility->AttachTo(RootComponent);
        SpecialAbility->RegisterComponent();
    }
    else
    {
        // Remove the reference, this will allow the created version to be
        // garbage collected later. May not be the most performant solution.
        SpecialAbility = nullptr;
    }
}

Hi !

Four years later, I’m having the exact same problem as Swiftle. Anyone found a solution ?

Actually my goal is to have a default component in C++ used in an actor, also in C++ but to be able to inherit the component in Blueprint and be able to replace it in the actor also from editor. It would be quite helpful to help some game designers being able to prototype things by themselves without having to dig into the C++ code.

On owning actor call code below (assuming SpecialAbility is pointer to you component):

this->AddInstanceComponent(SpecialAbility);

this will make sure you can see the component in Details panel (World outliner)