How do I make an Actor in a Plugin show up in the ClassViewer?

I’m currently familiarizing myself with UE4’s plugin system.

One project is to create an actor and add it to a level. It prints the current FPS every five seconds.

I’ve written the plugin and the actor. I’ve enabled the plugin and turned off both the blueprint filter and placeable filter (even though everything is placeable by default).

For some reason though the actor is not showing up in the class viewer which means I can’t place it inside the level.

Here is the code for the actor

FPSPrinterActor.h

#pragma once


#include "FPSPrinterActor.generated.h"

UCLASS()
class AFPSPrinterActor: public AActor
{
	GENERATED_UCLASS_BODY()

	float Timer;
	float FramesGoneBy;

	virtual void BeginPlay() OVERRIDE;
	virtual void TickActor(float DeltaSeconds, ELevelTick TickType, FActorTickFunction& ThisTickFunction) OVERRIDE;
};

FPSPrinterActor.cpp

#include "FPSPrinterPrivatePCH.h"


AFPSPrinterActor::AFPSPrinterActor(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	Timer = 0.0f;
	FramesGoneBy = 0.0f;
}



void AFPSPrinterActor::BeginPlay()
{
	Super::BeginPlay();

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Hello World!"));
	}
}

void AFPSPrinterActor::TickActor(float DeltaSeconds, ELevelTick TickType, FActorTickFunction& ThisTickFunction)
{
	Super::TickActor(DeltaSeconds, TickType, ThisTickFunction);

	FramesGoneBy++;

	Timer += DeltaSeconds;
	if (Timer >= 5.0f)
	{
		Timer = 0.0f;
		FramesGoneBy = 0.0f;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Current FPS:"));
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(static_cast<int>(FramesGoneBy / Timer)));
		}
	}
}

After looking at the source code of other plugin’s that supply actors (cable, paper2D) I noticed all of their implementation for the actor was in a component that they set as the root component.

I moved my implementation to a component and it appears to have worked. Whether it was just a side effect or the root cause of it working I can’t say (and would love to know the answer to).

I just had to set view type in asset browser to include Plugins.

You just need to export your class, which you are not doing to your plugin’s actor class.
Instead of doing that:

UCLASS()
class AFPSPrinterActor: public AActor

Do this:

UCLASS()
class MODULENAME_API AFPSPrinterActor: public AActor

Where “ModuleName” is the name of the Module you declare inside your .uplugin file; if you name it like this:

"Modules": [
	{
		"Name": "MyCoolPlugin",
		"Type": "Runtime",
		"LoadingPhase": "Default"
	}
]

Than your generated API to use is actually:

MYCOOLPLUGIN_API