x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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)));
         }
     }
 }

Product Version: Not Selected
Tags:
more ▼

asked May 29 '14 at 08:48 PM in C++ Programming

avatar image

Wizardoutlaw
26 3 5 8

avatar image jakeslack27 Aug 22 '16 at 12:07 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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).

more ▼

answered Jun 02 '14 at 09:38 PM

avatar image

Wizardoutlaw
26 3 5 8

avatar image BrUnO XaVIeR Aug 22 '16 at 04:34 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question