diff --git a/Assets/PerfectWorld/Scripts/UI/ShopUIManager.cs b/Assets/PerfectWorld/Scripts/UI/ShopUIManager.cs index f1d4ca5684..40d730a0a6 100644 --- a/Assets/PerfectWorld/Scripts/UI/ShopUIManager.cs +++ b/Assets/PerfectWorld/Scripts/UI/ShopUIManager.cs @@ -144,9 +144,11 @@ public class ShopUIManager : MonoBehaviour List 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();