I have an interface declared and called in C++. There are implementations in C++ and blueprints.
I am following the documentation (Interfaces in Unreal Engine | Unreal Engine 5.2 Documentation), which doesn’t have an essencial part (how do I call the method?).
So, I declared and implemented as the documentation says, and I am calling using the following code:
IButtonControlledUI::Execute_OnFocusReceivedByFocusManager(FocusedObject, this);
where IButtonControlledUI is my class, OnFocusReceivedByFocusManager is the method and FocusedObject is the owner.
It’s working in blueprints, but not in C++. The implemenation is not being called. The generated code (see the screenshot bellow) is not calling the OnFocusReceivedByFocusManager_Implemenation method. What must I do?
Fore more details, these are the declaration and implementation:
The interface:
UINTERFACE(Blueprintable)
class UButtonControlledUI : public UInterface
{
	GENERATED_UINTERFACE_BODY()
};
class IButtonControlledUI
{
	GENERATED_IINTERFACE_BODY()
public:
	UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Button Controlled UI")
	void OnFocusReceivedByFocusManager(AFocusManager* FocusManager);
	UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Button Controlled UI")
	void OnFocusLostByFocusManager(AFocusManager* FocusManager);
};
The class that implements the interface (.h):
UCLASS()
class SQUAD51_API UActionMenuItem : public UTextBlock, public IButtonControlledUI
{
	GENERATED_BODY()
	
public:
	virtual void OnFocusReceivedByFocusManager_Implementation(AFocusManager* FocusManager) override;
	virtual void OnFocusLostByFocusManager_Implementation(AFocusManager* FocusManager) override;
};
The class that implements the interface (.cpp, these are the methods that are’t called):
void UActionMenuItem::OnFocusReceivedByFocusManager_Implementation(AFocusManager* FocusManager)
{
	SetOpacity(1.f);
}
void UActionMenuItem::OnFocusLostByFocusManager_Implementation(AFocusManager* FocusManager)
{
	SetOpacity(0.5f);
}
And this is how I called: (FocusedObject appears to be correct, I checked it):
if (FocusedObject->GetClass()->ImplementsInterface(UButtonControlledUI::StaticClass()))
				IButtonControlledUI::Execute_OnFocusReceivedByFocusManager(FocusedObject, this);


