I have class A: BaseCharacter, class B: PoV_System and interface conntected to class A and B: PovInterface.
PovInterface.h:
public:
void SetCurrentWidgetHolder(APoV_System * x);
FORCEINLINE APoV_System* GetCurrentWidgetHolder() const { return CurrentWidgetHolder; }
private:
APoV_System* CurrentWidgetHolder;
BaseCharacter.cpp:
//Object found - display widget.
if (RV_Hit.bBlockingHit && object->GetClass()->IsChildOf(APoV_System::StaticClass()))
{
SetCurrentWidgetHolder(PtrToAnActor); //IPovInterface
PtrToAnActor->ShowWidget();
} else {
APoV_System* WidgetToClose = GetCurrentWidgetHolder(); //IPovInterface
//Object found previously, but disappeared - hide widget.
if (WidgetToClose != nullptr) {
WidgetToClose->HideWidget();
SetCurrentWidgetHolder(nullptr); //IPovInterface
}
}
and PoV_System.cpp:
PoV_System* WidgetToClose = IPovInterface::GetCurrentWidgetHolder(); //IPovInterface - not working
if (WidgetToClose != nullptr)
{
WidgetToClose->HideWidget();
SetCurrentWidgetHolder(nullptr);
}
**
Problem: I want IPovInterface to store CurrentWidgetHolder variable and share it between class A and B. In BaseCaharacter.cpp setting and getting variable seems to work properly, but when I want get it from PoV_System, it always returns NULL.
NOTE: Getting in PoV_System execute only when widget is visible, so CurrentWidgetHolder should be PtrToAnActor.
**