I dynamically added a child widget via column/row values.
However, widgets that belong to other widgets (such as WBP_InventoryPanel belong to WBP_MainMenu) are not updated when the column/row value were changed, but remain in the state they were in when they were added.
Is there no way?
//UInventoryPanel.h
UPROPERTY(EditDefaultsOnly, Category = "Inventory")
TSubclassOf<UInventoryItemSlot> InventorySlotClass;
UPROPERTY(EditDefaultsOnly, Category = "Inventory")
int32 SlotColumnSize;
UPROPERTY(EditDefaultsOnly, Category = "Inventory")
int32 SlotRowSize;
I try it in the editor/initialize method, but it still doesn’t update.
void UInventoryPanel::MakeSlots()
{
InventoryPanel->ClearChildren();
InventorySlots.Empty();
for (int Row = 0; Row < SlotRowSize; ++Row)
{
for (int Column = 0; Column < SlotColumnSize; ++Column)
{
UInventoryItemSlot* ItemSlot = CreateWidget<UInventoryItemSlot>(this, InventorySlotClass);
InventoryPanel->AddChildToUniformGrid(ItemSlot ,Row, Column);
InventorySlots.Add(ItemSlot);
}
}
}
void UInventoryPanel::NativeOnInitialized()
{
Super::NativeOnInitialized();
MakeSlots();
}
void UInventoryPanel::NativePreConstruct()
{
Super::NativePreConstruct();
MakeSlots();
}
void UInventoryPanel::NativeConstruct()
{
Super::NativeConstruct();
MakeSlots();
}
void UInventoryPanel::SynchronizeProperties()
{
Super::SynchronizeProperties();
MakeSlots();
}
void UInventoryPanel::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
MakeSlots();
}