Fix unexpect item order in each tab of mall
This commit is contained in:
@@ -144,9 +144,11 @@ public class ShopUIManager : MonoBehaviour
|
||||
List<GShopItem> categoryItems = GetItemsForCategory(currentCategory);
|
||||
|
||||
// Create item panels using pooling
|
||||
int siblingIndexCounter = 0;
|
||||
foreach (GShopItem item in categoryItems)
|
||||
{
|
||||
CreateItemPanelFromPool(item);
|
||||
CreateItemPanelFromPool(item, siblingIndexCounter);
|
||||
siblingIndexCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +185,7 @@ public class ShopUIManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void CreateItemPanelFromPool(GShopItem item)
|
||||
void CreateItemPanelFromPool(GShopItem item, int targetSiblingIndex)
|
||||
{
|
||||
GameObject itemPanel = null;
|
||||
|
||||
@@ -204,8 +206,10 @@ public class ShopUIManager : MonoBehaviour
|
||||
if (itemPanel != null && itemContainer != null)
|
||||
{
|
||||
// Set parent and position
|
||||
itemPanel.transform.SetParent(itemContainer);
|
||||
itemPanel.transform.SetParent(itemContainer, false);
|
||||
itemPanel.transform.localScale = Vector3.one;
|
||||
// Ensure deterministic ordering regardless of pool retrieval order
|
||||
itemPanel.transform.SetSiblingIndex(targetSiblingIndex);
|
||||
|
||||
// Setup the panel
|
||||
ShopItemPanel itemPanelScript = itemPanel.GetComponent<ShopItemPanel>();
|
||||
|
||||
Reference in New Issue
Block a user