I have two modules, main and UI
the UI where it contains the widget blueprints is referencing to main module where is located the UI maneger so main module can’t reference UI to create Inventory by accessing its Widgetbluprint.
All of them called in BeginPlay overrided function.
So
From main module, UI_manager.h
DECLARE_DELEGATE(FDele_init_inventory_manager)
DECLARE_DELEGATE_OneParam(FDele_open_inventory_manager, bool)
FDele_init_inventory_manager dele_init_inventory_manager;
FDele_open_inventory_manager dele_open_inventory_manager;
And the cpp
void AUI_manager::Init_inventory()
{
dele_init_inventory_manager.ExecuteIfBound();
}
void AUI_manager::Open_or_close_inventory(bool _is_opened)
{
dele_open_inventory_manager.ExecuteIfBound(_is_opened);
}
And the Inventory.h
public:
UFUNCTION()
void Init_inventory_manager();
UFUNCTION()
void Open_or_close_inventory(bool _is_opened);
cpp
void AInventory::BeginPlay()
{
Super::BeginPlay();
auto p_ui_manager = Get_UI_manager();
p_ui_manager->dele_init_inventory_manager.BindUObject(this, &AInventory_manager::Init_inventory_manager);
p_ui_manager->dele_open_inventory_manager.BindUObject(this, &AInventory_manager::Open_or_close_inventory);
}