#pragma once
#include "ItemActionsInterface.generated.h"
UINTERFACE(Blueprintable)
class UItemActionsInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class IItemActionsInterface
{
GENERATED_IINTERFACE_BODY()
public:
UFUNCTION(BlueprintNativeEvent, Category = "Pickup", meta = (DisplayName = "Pickup Item"))
bool PickupItem(class AItemActor* InItemActor);
UFUNCTION(BlueprintNativeEvent, Category = "Match", meta = (DisplayName = "Match Item"))
bool MatchItem(int32 MatchType);
};
IItemActionsInterface::Execute_PickupItem(OtherActor, Item);
It is ok in C++. But can not find the Pickup Item in Blueprint Context Menu.
I was using Unreal Engine 4.12.3
I tried many methods, but all failed. I think this is a bug in engine.
The PickupItem(Message) is not appeared even after cast to ItemActionsInterface in Blueprint.
Interface created in Editor is all OK.
Have you tried making your interface UFunctions ‘BlueprintCallable’?
Kris
(Kris)
June 26, 2016, 2:05am
5
I have an C++ interface setup with BlueprintNativeEvent & BlueprintCallable.
Give this a try.
.h:
#pragma once
#include "ItemActionsInterface.generated.h"
UINTERFACE(Blueprintable)
class UItemActionsInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class IItemActionsInterface
{
GENERATED_IINTERFACE_BODY()
public:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pickup", meta = (DisplayName = "Pickup Item"))
bool PickupItem(class AItemActor* InItemActor);
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Match", meta = (DisplayName = "Match Item"))
bool MatchItem(int32 MatchType);
};
.cpp:
// Copyright bla bla bla
#include "<YourGame>.h"
#include "ItemActionsInterface.h"
UItemActionsInterface::UItemActionsInterface(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
bool IItemActionsInterface::PickupItem_Implementation(class AItemActor* InItemActor)
{
}
bool IItemActionsInterface::MatchItem_Implementation(int32 MatchType)
{
}
Thank you, Kris.
BlueprintNativeEvent and BlueprintCallable can both exist. I just tried BlueprintCallable , but got a compiler error.