public void CreateEquipmentWindow(List <Item> items, OnSubmitSlot onPickUpItemCallBack = null, OnSelectSlot onSelectSlotCallBack = null, bool destroyAdictionSlots = true) { if (items.Count == 0) { if (itemtext) { itemtext.text = ""; } if (slots.Count > 0 && destroyAdictionSlots) { for (int i = 0; i < slots.Count; i++) { Destroy(slots[i].gameObject); } slots.Clear(); } return; } bool selecItem = false; onSubmitSlot = onPickUpItemCallBack; onSelectSlot = onSelectSlotCallBack; if (slots == null) { slots = new List <ItemSlot>(); } var count = slots.Count; if (count < items.Count) { for (int i = count; i < items.Count; i++) { var slot = Instantiate(slotPrefab) as ItemSlot; slots.Add(slot); } } else if (count > items.Count) { for (int i = count - 1; i > items.Count - 1; i--) { Destroy(slots[slots.Count - 1].gameObject); slots.RemoveAt(slots.Count - 1); } } count = slots.Count; for (int i = 0; i < items.Count; i++) { ItemSlot slot = null; if (i < items.Count) { slot = slots[i]; slot.AddItem(items[i]); slot.CheckItem(items[i].isInEquipArea); slot.onSubmitSlotCallBack = OnSubmit; slot.onSelectSlotCallBack = OnSelect; var rectTranform = slot.GetComponent <RectTransform>(); rectTranform.SetParent(contentWindow); rectTranform.localPosition = Vector3.zero; rectTranform.localScale = Vector3.one; if (currentItem != null && currentItem == items[i]) { selecItem = true; SetSelectable(slot.gameObject); } } } if (slots.Count > 0 && !selecItem) { StartCoroutine(SetSelectableHandle(slots[0].gameObject)); } if (onCompleteSlotListCallBack != null) { onCompleteSlotListCallBack(slots); } }