So what I’m trying to setup is basically a USceneComponent that I can add with the ‘add component’ button in blueprints that comes with a UStaticMeshComponent already attached. Not sure that this is possible but it seems like it should be.
Here’s the relevant part of the class:
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = CustomGroup)
class UCustomComponent : public USceneComponent
{
GENERATED_BODY()
public:
UCustomComponent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Custom")
UStaticMeshComponent* CustomMesh;
}
And the constructor:
UCustomComponent::UCustomComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
CustomMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Custom Mesh"));
if (CustomMesh)
{
CustomMesh->SetupAttachment(this);
}
}
When I add UCustomComponent to a blueprint it doesn’t show anything nested. In the details panel I can see properties of both components but I can’t tell which is which 'cause they aren’t categorized. Also, it seems like they’re using the same transform as changing one affects the other.