How could I expose a class to the editor, so it would be editable the same way blueprint-actors can (adding a object to it, for instance). And by that I don’t mean adding objects to it in-game, but rather in the editor (for instance, adding player a collision capsule. It is always there, so might as well have it added there through the editor). I hope you understand what I mean.
You can’t do this because when you create a new Blueprint what you’re really doing is creating a new class. What you can do is create a base class in code and use this as a base class when you create a new Blueprint. You might need to specify the class as Blueprintable, though if your base class inherits from Actor it should already be specified.
A sample here, hope it answer to you question :
.h
UCLASS()
class ADeck : public AActor
{
GENERATED_UCLASS_BODY()
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Default)
TSubobjectPtr<class UStaticMeshComponent> StaticMeshComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Default)
TArray<AActor*> AllCardsActor;
UFUNCTION(BlueprintCallable, Category = Default)
void InitDeck();
};
.cpp
ADeck::ADeck(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
StaticMeshComponent = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Static Mesh Component"));
StaticMeshComponent->bOwnerNoSee = false;
StaticMeshComponent->bCastDynamicShadow = false;
StaticMeshComponent->CastShadow = false;
StaticMeshComponent->BodyInstance.SetObjectType(ECC_WorldDynamic);
StaticMeshComponent->BodyInstance.SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
StaticMeshComponent->BodyInstance.SetResponseToAllChannels(ECR_Block);
StaticMeshComponent->bGenerateOverlapEvents = false;
StaticMeshComponent->SetHiddenInGame(false);
RootComponent = StaticMeshComponent;
}
void ADeck::InitDeck()
{
...
}
In the editor, you can create a blueprint based on this class. they all have this Static mesh component as root component.
Cheers
okay, I’ll give it a shot