Download

Class which was marked abstract was trying to be loaded.

Hi everyone! I wrote simple code:

.h



class HORRORGAME_API AScreamSystem : public ACharacter
{
	GENERATED_UCLASS_BODY()

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=MeshTrigger)
    TSubobjectPtr<class UMeshComponent> meshTrigger;

	void Tick(float DeltaSeconds);
};


.cpp



AScreamSystem::AScreamSystem(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	meshTrigger = PCIP.CreateDefaultSubobject<UMeshComponent>(this, TEXT("Mesh"));
}


void AScreamSystem::Tick(float DeltaSeconds)
{
	GEngine->AddOnScreenDebugMessage(1, 10, FColor::Green, "Hello, world");
}



I don’t have errors but Visual Studio doesn’t compiles it

In log:
Class which was marked abstract was trying to be loaded. It will be nulled out on save. Mesh MeshComponent

What should I do?

UMeshComponent is an abstract class - see the documentationand you will see it starts with UCLASS(Abstract).

This means you must first create a subclass of UMeshComponent and use that as your meshTrigger.

Please write me example

UMeshComponent is abstract class, which cannot be instantiated, so you need to create derived class instead, which itself is not abstract:

As an example:


meshTrigger = PCIP.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("MESH"));

You can see all derived classes in documentation. :slight_smile:

Thank you!