IEnumerator ReturnPool() { bi.transform.localPosition = Vector3.MoveTowards(bi.transform.localPosition, new Vector3(-532, -7, 0), Speed); yield return(new WaitForSeconds(0.0f)); Objectpool.Return(item); }
public void Pickup(BaseItem baseItem) { bool isFind = false; //item = Instantiate(Resources.Load("Preb/UItem"), transform.position, transform.rotation) as GameObject; item = Objectpool.Get("UItem", transform.position, transform.rotation) as GameObject; imagesingle = item.transform.GetComponent<Image>(); imagesingle.overrideSprite = Resources.Load(baseItem.Icon,typeof(Sprite)) as Sprite; for(int i=0;i<UIBags.Length;i++) { if(UIBags[i].transform.childCount>0) { if(imagesingle.overrideSprite.name == UIBags[i].transform.GetChild(0).transform.GetComponent<Image>().overrideSprite.name) { Debug.Log("相等"); isFind = true; index = UIBags[i].transform.GetChild(0).transform.GetChild(0).GetComponent<Text>(); IndexInt = int.Parse(index.text); IndexInt += 1; IndexStr = IndexInt.ToString(); index.text = IndexStr; StartCoroutine(ReturnPool()); // Destroy(item); item.transform.SetParent(storage.transform); } } } if(isFind==false) { for (int i = 0; i < UIBags.Length; i++) { if (UIBags[i].transform.childCount == 0) { item.transform.SetParent(UIBags[i].transform); item.transform.localPosition = Vector3.zero; item.transform.localScale = new Vector3(1, 1, 1); ItemInfo.StoreItem(UIBags[i].transform.name, baseItem); break; } } } }
private void Awake() { SharedInstance = this; }
IEnumerator ReturnPool() { yield return new WaitForSeconds(0.0f); Objectpool.Return(item); }