Cant add StaticMeshComponent derived class to BP actor

I have created a custom class that derives from “UStaticMeshComponent” and adds some “controll”-features
and a MaterialInstance (Its a light, that can be turned on and off)

Everything compiles

If i try to move the class from the ContentBrowser (Source Folder) to my Blueprint-Actor it wont add an object of the class to the actor,
there is no “red cross” or anything else, that would tell me, that im not allowed to add it, so it seems like a bug for me.

Is it not allowed to add a StaticMeshComponent derived class to a BP actor or am I missing something else?

did you tried to add it using “AddComponent” menu in blueprint editor? Is it appears there?

Hopefully I have understood the question.

Within your Blueprint Actor class you need to ‘Add Component’ and then select ‘Static Mesh’. After that on the right hand side there will be a static mesh drop down menu and a green box with ‘none’ written inside it. Click on that and select the static mesh you want to add.

Hope this helps.

No, it doesn’t show, could posting the source code help, maybe im missing something…

#pragma once

#include “CoreMinimal.h”
#include “Components/StaticMeshComponent.h”
#include “TrainLight.generated.h”

UCLASS(BlueprintType)
class METRO2_API UTrainLight : public UStaticMeshComponent
{
GENERATED_BODY()

UTrainLight();

#if WITH_EDITOR
void PostEditChangeProperty(struct FPropertyChangedEvent& e);
#endif

public:

void TurnOn(bool AsFrontLight = false);
void TurnOff();

bool IsFrontLight() {return bFrontLight;}
bool IsBackLight() {return bBackLight;}

private:

UPROPERTY(EditAnywhere)
bool bFrontLight = false;

UPROPERTY(EditAnywhere)
bool bBackLight = false;

UMaterialInstanceDynamic* MI_Light;

};

That would be fine if i wanted to add a blank StaticMeshComponent, but I want my custom class, that inherits from UStaticMeshComponent, see the code I posted above

For the UCLASS Macro, I use the following:

UCLASS( ClassGroup = ( CustomGroupName ), meta = ( BlueprintSpawnableComponent ) )

That then allows for the Component to appear in the editor.

If you’re wanting any of your functions to be usable in the Editor via Blueprints, you’ll need to make sure you use the UFUNCTION() macro.

And I would recommend still adding a UPROPERTY() macro ahead of your UMaterialInstanceDynamic declaration, just in case it doesn’t get GC’d out from under you! You can use it with no params, so it’ll be included in UBT, but not visible/editable in BPs.

Works great, thank you very much, but I still feel like Unreal could indicate such things a little bit more, because there was no feedback when I moved it from the content browser,

Anyways, thanks for your answer :slight_smile: