Esempio n. 1
0
        void InitPool()
        {
            GameObject poolNode = new GameObject("POOL");

            poolNode.SetActive(false);
            poolNode.transform.SetParent(transform, false);
            itemPool = new SimpleObjectPool <RectTransform>(() =>
            {
                GameObject itemObj = Instantiate(itemTemplate.gameObject);
                RectTransform item = itemObj.GetComponent <RectTransform>();
                itemObj.transform.SetParent(poolNode.transform, false);

                item.anchorMin = Vector2.up;
                item.anchorMax = Vector2.up;
                item.pivot     = Vector2.zero;
                //rectTrans.pivot = Vector2.up;

                itemObj.SetActive(true);
                return(item);
            }, (RectTransform item) => { if (item == null)
                                         {
                                             return;
                                         }
                                         item.transform.SetParent(poolNode.transform, false); }, poolSize);
        }