UFUNCTIONS not showing up in Blueprint

I have a simple Actor Component in Blueprint and just want to add a Function that is usable in blueprint, but whatever I do the function does not show up in the blueprint graph, when I add the component to an actor.

MyActorComponent.h

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MyActorComponent.generated.h"

UCLASS(Blueprintable, BlueprintType, ClassGroup = ("Test"), meta = (BlueprintSpawnableComponent))
class MRSVSPACEPLUGIN_API UMyActorComponent : public UActorComponent
{
	GENERATED_BODY()

public:	
	/** Please add a function description */
	UFUNCTION(BlueprintCallable, Category="Test")
	void MyTestFunction(FString TestInput);
};

MyActorComponent.cpp

#include "MyActorComponent.h"

void UMyActorComponent::MyTestFunction(FString TestInput)
{
	UE_LOG(LogTemp, Display, TEXT("MyTestFunction"));
}

I can add the component to an actor:

But I can’t see the function:

I tried adding different specifiers and metadata and even copied some code from another plugin that does this (and it works if I use the plugin), but I can’t get it to work in my code. What am I doing wrong?

Any help is greatly apprecciated!

Is the code in the plugin?
Try compiling using the “Modules” tab.

Perhaps you simply do not see the changes because the actual version of the code is not reloaded.

1 Like

how was the C++ class added to the project (like with the Editor “add C++ class”), do you have other C++ classes in the project, or is this the first one you added?
if you give the component a

public:
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=MyActorComponent)
    int32 TestInt = 42;

then build, you should be able to see the int in: the Details window for any instance of the Actor component, and by pulling off the instance of the Component in the blueprint graph.

If you do not see the integer in the details window for the component, or by pulling off the components instance then your code is not being built under the Unreal Build Tool (this is the primary way that stuff done in C++ gets revealed in the editor.

be sure to check the setup guild for you IDE (Epic has proving guides for Visual Studio, Visual Studio Code, XCode, and Rider.

1 Like

Thanks to all for the great help. The problem was actually my own fault.

I created the class in a “Editor” module in the plugin and wasn’t aware of the different module types. After I created a new module of type “Runtime” and moved the code there, I was able to spawn the object and call the function on it.

I am actually quite surprised that you can even spawn a blueprint object of a class which is in an Editor module as this class shouldn’t exist at runtime if I understood everything correctly. Perhaps someone knows if this is actually used for some kind of functionality I am not aware of.

it isn’t so much specific “functionality”, but rather default behavior.

under the Unreal Header Tool, and Unreal Build Tool any class that derives AActor/USceneComponent, and particularly those marked BlueprintSpawnable/BlueprintSpawnableComponente respectively can be instantiated into a World/Blueprint.

the Engine does no real checks for where the thing came from, and only if the Object has permissions, and visibility for the things it is doing.

under the Engine a Plugin can realistically do anything (there are some limitations, but for the most part if you can code it it can be in a plugin), the expectation is that core game code references and calls things about the plugin, and the plugin doesn’t care “specifically” about the core game code. The reason for this if you make your plugin in a generic enough way, you could take that plugin and integrate it into a different project.

for example if you made a Footsteps plugin, that detects when a given sceneComponent on the Actor touches the “Ground” which plays a footstep sound, and then if the surface has given properties spawns a decal for a footstep, or deforms maybe snow/mud. All of this logic could be put into a plugin , and then you could take and re-use it across several projects, or even put it up on the Market Place (now FAB) and other developers could use that plugin in their own projects. But for this plugin to function you would have to be able to instantiate those SceneComponents onto a given actor C++/Blueprint

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.