//装备物品 public void Equip(int id) { ObjectInfo equipInfo = ObjectsInfo._instance.GetObjectInfoByID(id); GameObject parent = null; switch (equipInfo.equipType) { case EquipType.Headgear: parent = head; break; case EquipType.Armor: parent = armor; break; case EquipType.R_Hand: parent = r_hand; break; case EquipType.L_Hand: parent = l_hand; break; case EquipType.Shoe: parent = shoe; break; case EquipType.Accessory: parent = accessory; break; } EquipItem equipItem = parent.GetComponentInChildren <EquipItem>(); if (equipItem != null) //当前部位有装备 { Debug.Log("有装备"); int currentEquipID = equipItem.equipID; equipItem.SetEquipItem(id); InventoryManger._instance.GetItemID(currentEquipID); } else //当前部位没有穿戴装备 { Debug.Log("无装备"); Instantiate(equipItemPrefab, parent.transform); equipItem = parent.GetComponentInChildren <EquipItem>(); equipItem.SetEquipItem(id); } }