Hi,
I have a C++ Interface which forces the implementing Actor to have a simple Function: GetSomeComponent
(in this case a component representing a resource like Health or Mana). This function needs to be available in Blueprints so it specifies UFUNCTION(BlueprintCallable)
.
In order to be aBlueprintCallable
function the interface specifier needs to be NotBlueprintable
And to be able to check in Blueprints that an Actor inplements the interface the specifier BlueprintType
.
The interface looks like this:
UINTERFACE(MinimalAPI, BlueprintType, NotBlueprintable)
class UHealthInterface : public UInterface
{
GENERATED_BODY()
};
/**
* Force the implementing class to have / return a Resource Component representing Health.
*/
class GAME_API IHealthInterface
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
virtual class UResourceComponent* GetHealthResourceComponent() const = 0;
};
So far so good. But the issue is, I can’t cast the Actor
to the HealthInterface
type in blueprints, it’s not showing up. In the following example I try to cast in in a Widget Blueprint:
So now comes the weirdest part:
I solved the problem somehow by doing the following:
- removing the interface specifier
NotBlueprintable
as well as the function specifierBlueprintCallable
- compile the project
- now I was able to get the type cast node:
- problem is now that I can’t (as required) to call
GetHealthResourceComponent()
from blueprints - I kept the type cast node in blueprints went back to C++ and added back
NotBlueprintable
andBlueprintCallable
and compiled - went back to blueprints and now I can call the function as wanted from the interface:
My question is, is the thing I want to do valid and it is this an unreal bug if BlueprintType
and NotBlueprintable
is used together that the type cast does not show in blueprints?
Or did I just do an evil hack which is not intended to work and falls upon my feet later?