Uniform Grid Panel setup

Also interested in the above. I’m trying to make an automap for a grid-based game, and some help with populating this grid with returns from ray traces, for instance, would be immensely appreciated.

Hi, how do you make sense of the percentage? I can’t figure it out.
How does 4%x1 translate to: “I want this in column 1”, for example?
Thanks.

It’s not percentage, it’s modulo.

2 Likes

Hi,

How would you go about updating a UniformGrid list?

I have a UniformGrid that contains 32 ‘InventorySlots’. (Children)

When the Player picks something up, the inventory array is updated, and a delegate triggers a “refreshInventoryGrid” function.

My current refreshInventory solution is to delete all children of the UnifformGrid and start iterating over the Inventory array to Create Inventory slots with the inventory Item data. Then adding these slots to the correct Row/Column.
When there are no more Item’s in the inventory array, I keep creating empty InventorySlots until I reach 32 inventorySlots.

This means that for every pickup / drop of an item 32 widgets are being deleted and then 32 new widgets are made, which doesn’t seem performant.

I could also start with 32 empty InventorySlots, then iterate over the Inventory Items and update the InventorySlots ItemData. But then I will have to cast for each inventory item… And that every time the inventory Array is altered.

  • UPanelWidget* SlotWidet = UniformGrid.GetChildAt( GetNextFreeSlotIndex() );
  • Cast this panelWidget to InventorySlot widget
  • InventorySlotWidget->AddItemData( InventoryItem); (This will pass the item data to the inventory slot)

The problem here is the complexity of finding the InventorySlot that need to be deleted / altered + the cost of the Cast to InventorySlot.

TL;DR.
Is it best to update a UniformGridPanel by deleting all children, create 32 new widgets and fill them in the correct location in the UniformGridPanel
or
Create 32 widgets at the beginning of the game and for every Inventory update, pass the new ItemData to the correct widgets. (BUT for every item in the inventory a cast will be needed)