"Error: CDO for class ...not load" when referencing a Blueprint of a custom plugin

Hi,

I am trying to create a simple plugin “BasicCollectibles” for my game with C++ in VS2022. Everything was working fine:

  • Create the plugin
  • Add an interface “CollectibleInterface”
  • Add an implemtation class deriving from AActor “BasePickup”
  • Create a BP within the content folder of my plugin (BP_BasePickup) which derives from BasePickup and therefore inherits the interface “CollectibleInterface”

Then I extended the BP_ThirdPersonCharacter from Unreals Template by a collision sphere and added this little logic:

I dropped a few instances of BP_BasePickup into the level and the output showed the number of pickups within the CollisionSphere.

So far so good, but when I changed the “Class Filter” to BP_BasePickup from my plugin it works fine until I close the editor.

After attempting to reopen the UE editor again it gives me this error:

„Error: CDO for class /BasicCollectibles/BP_BasePickup.BP_BasePickup_C did not load!“

This will occur until I delete the BP_BasePickup.uasset manually from the project.

I also tested the “Class Filter” with a BP_class within the project. It was working fine, no problems. So I am guessing I did sth. wrong with my plugin here.

What am I missing here? What am I doing wrong?

CollectibleInterface.h:

#pragma once

#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "CollectibleInterface.generated.h"

UINTERFACE(MinimalAPI, Blueprintable)
class UCollectibleInterface : public UInterface
{
	GENERATED_BODY()
};

class BASICCOLLECTIBLES_API ICollectibleInterface
{
	GENERATED_BODY()
public:
	void OnCollected(AActor* Collector);
};

CollectibleInterface.cpp:

#include "CollectibleInterface.h"

BasePickup.h:

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CollectibleInterface.h"

#include "BasePickup.generated.h"

UCLASS(Blueprintable)
class BASICCOLLECTIBLES_API ABasePickup : public AActor, public ICollectibleInterface
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ABasePickup();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	void OnCollected_Implementation(AActor* Collector) override;
};

BasePickup.cpp:

#include "BasePickup.h"

/* Sets default values */
ABasePickup::ABasePickup()
{
	PrimaryActorTick.bCanEverTick = true;
}

// Called when the game starts or when spawned
void ABasePickup::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void ABasePickup::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

void ABasePickup::OnCollected_Implementation(AActor* Collector)
{
	if (Collector)
	{
		UE_LOG(LogTemp, Log, TEXT("Collected by: %s"), *Collector->GetName());
	}
	Destroy();
}

Hi,

Hope you’re doing well!

Try to set your plugin’s LoadingPhase as PreDefault, in your <your_plugin>.uplugin, e.g.:

"Modules": [
  {
    "Name": "MyPlugin",
    "Type": "Runtime",
    "LoadingPhase": "PreDefault"
  }
]

I think this will solve your issue, if not let me know.

Hope that helps - take care.

Wow, super fast answer and solution. I changed

BasicCollectibles.uplugin
from

{
	[...]
	"MarketplaceURL": "",
	"SupportURL": "",
	"CanContainContent": true,
	"IsBetaVersion": false,
	"IsExperimentalVersion": false,
	"Installed": false,
	"Modules": [
		{
			"Name": "BasicCollectibles",
			"Type": "Runtime",
			"LoadingPhase": "Default"
		}
	]
}

to

{
	[...],
	"MarketplaceURL": "",
	"SupportURL": "",
	"CanContainContent": true,
	"IsBetaVersion": false,
	"IsExperimentalVersion": false,
	"Installed": false,
	"Modules": [
		{
			"Name": "BasicCollectibles",
			"Type": "Runtime",
			"LoadingPhase": "PreDefault"
		}
	]
}

cleaned up and rebuild my project and voilà: it worked out of the box.

1000 thx. Now I am much better! Have a nice day!

1 Like