Functions of c++ UINTERFACE does not show up in blueprint

Hello all

I have created a UINTERFACE in c++ so I can cast to it in blueprints and call functions on it unfortunately the functions do not appear in blueprints.

They do appear when editing the objects that implements it however when casting to the interface and dragging off the pin, the functions do not appear.

Some code for a simple test function:




ISomeInterface.h

UINTERFACE(BlueprintType, Blueprintable)
class USomeInterface : public UInterface
{
	GENERATED_UINTERFACE_BODY()
};

class ISomeInterface
{
	GENERATED_IINTERFACE_BODY()

public:
	virtual FString ToString() const = 0;

	UFUNCTION(BlueprintNativeEvent)
	FString SomeFunction(int32 SomeInt);
};

USomeObject.h

UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
	FString SomeFunction(int32 SomeInt);
	virtual FString SomeFunction_Implementation(int32 SomeInt) override
	{
		return "SomeString";
	}



Anybody know what is wrong or could it be this feature has simply not been implemented and I would have to make static wrapper functions that take the interface as parameter just to make it work?:frowning:

Thanks

Try adding a category:


class ISomeInterface
{
    GENERATED_IINTERFACE_BODY()

public:
    virtual FString ToString() const = 0;

    UFUNCTION(Category = "SomeCategory", BlueprintNativeEvent)
    FString SomeFunction(int32 SomeInt);
};

Ah my bad I didn’t add those in the example. I have already tried with categories on as well but to no avail.

You need to define the BlueprintCallable bit in the interface. After casting to the interface, the editor doesn’t know about your derived implementation (because it could be any class that implements the interface.)

Oh yeah got it to work thanks.

I have not used the ImplementableNativeEvent a whole lot and in those cases it has just been to so that it was possible to overwrite in blueprint but not that I actually did so. I did not know you needed BlueprintCallable as well.

The only reason why I added it to the class was because I saw it in an example:P

Well thanks again anyway.