private void CreateCell(int idx)
        {
            ViewPoolObject viewPoolObject = this.viewPool.GetPoolObject(this.cellName);
            GameObject     gameObject;

            if (viewPoolObject == null)
            {
                gameObject          = UnityEngine.Object.Instantiate <GameObject>(this.transViewCell.gameObject);
                gameObject.name     = this.cellName;
                viewPoolObject      = gameObject.AddComponent <ViewPoolObject>();
                viewPoolObject.Name = this.cellName;
                viewPoolObject.Id   = ++this.cellId;
                viewPoolObject.Obj  = gameObject;
            }
            else
            {
                gameObject = viewPoolObject.Obj;
            }
            float y = (this.transContent.sizeDelta.y - this.cellHeight) * 0.5f - this.cellHeight * (float)idx;

            gameObject.transform.localPosition = new Vector3(gameObject.transform.localPosition.x, y, gameObject.transform.localPosition.z);
            gameObject.SetActive(true);
            gameObject.transform.SetParent(this.transContent, false);
            this.dictViewPool.Add(idx, viewPoolObject);
            gameObject.GetComponent <ScrollIndexCallback>().FNScrollCellIndex(idx);
        }
Exemple #2
0
 public void AddPoolObject(ViewPoolObject poolObject, GameObject objPool)
 {
     if (!this.dictCell.ContainsKey(poolObject.Name))
     {
         Stack <ViewPoolObject> value = new Stack <ViewPoolObject>();
         this.dictCell.Add(poolObject.Name, value);
     }
     this.dictCell[poolObject.Name].Push(poolObject);
     poolObject.Obj.SetActive(false);
     poolObject.Obj.transform.SetParent(objPool.transform, false);
 }