Functions of UObject derived class not accessible in blueprints

Hi,
I created a C++ class based on UObject and now I’m trying to create a varaible of this type in a blueprint and call a function on it.
The header looks like this:

#pragma once

#include "UObject/UObject.h"
#include "Greeter.generated.h"

UCLASS(BlueprintType)
class MYPRJ_API UGreeter : public UObject
{
	GENERATED_BODY()
public:
	UGreeter();
	UFUNCTION(BlueprintCallable, Category = Default)
	void Greet();
	~UGreeter();
};

And the source like this:

#include "myprj.h"
#include "Greeter.h"

UGreeter::UGreeter()
{
}

void UGreeter::Greet()
{
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("Hello!"));
}

UGreeter::~UGreeter()
{
}

The problem is that the Greet() function is not accessible in the blueprint editor.
What did I do wrong?

You mean AActor?
It doesn’t need to be an actor. I won’t be placing it in a level.
I need a C++ type which I can use as a blueprint variable and call functions on it.
Is it correct that UObject is all I need to extend from to get an Unreal-managed object that can be used for the above?

I turns out that instantiating UObject-based classes in blueprint is still not supported in Unreal Engine 4.
So the answer to my question is: It cannot be done at this point.

I don’t think that is correct, i am using a class derived from uobject and I am able to call its functions just fine from blueprint. While instantiating a UObject might not be supported (haven’t checked) from a class variable, you can have an actual object variable and call its functions. If you tried that and it still did not work, I recommend removing the BlueprintType tag and the MYPRJ_API, since those are the only two things you have that are different from mine.

Well, if I remove BlueprintType from the UCLASS() macro my type will not be visible in the blueprint editor at all. I will not be able to create a variable of my type in a blueprint. See https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Classes/Specifiers/BlueprintType/index.html

Actors and structs work better than Objects when dealing with blueprints.
maybe try making Greet() a static function.

Hey slstlr

Could you make an instance of the UGreeter a variable (UPROPERTY) of the base class of wherever you want to instantiate it? Lets say in the levelscriptactor, or the gamemode, character class, whatever? I’d have thought you could access that variable from the BP?