老师 我想把背包整理下 我是按格子里面的id记录下来 然后通过大小排序下 再通过从小到大实例化到格子里面去 但是 物品的数目要怎么记录下来的 已经排序了 id都乱了 有的物品是可以放一起的 怎么通过id去获得物品个数
   public void OnClear()
    {
        List<int> listID = new List<int>();
        foreach(Slot slots in slot)
        {
            if (slots.transform.childCount > 0 )
            {
                listID.Add(slots.id);
            }
        }
        foreach (Slot slots in slot)
        {
            if (slots.transform.childCount > 0)
            {
                DestroyImmediate(slots.GetComponentInChildren<Item>().gameObject);
            }
        }
        SelectSort(listID);//通过简单排序的
            foreach (var temp in listID)
            {
                StroeItem(temp);
                Debug.Log(temp);
            }
    }