示例#1
0
        private void CreateCell()
        {
            //Ex.Logger.Log("CreateCell", mCreateWithUpdate, Scheduler.GetTimer());
//             Value value = this.mValues[this.mKeepIndex];
//             GameObject cell = HS_ViewManager.UIAddChild(mGridContent.gameObject, mCellPrefab);
//             cell.name = "CellPrefab";
//             mValues[mKeepIndex].cell = cell.GetComponent<HS_UIListViewCell>();
//             if (this.onInit != null)
//             {
//                 this.onInit(this, value.cell, value.data);
//             }
            GameObject cell  = null;
            int        index = mKeepIndex % mCellCount;// 0 % 6 = 0 | 7 % 6 = 1
            Value      value = this.mValues[index];

            if (mCellCount > cellCount || value.cell == null)
            {
                cell = HS_ViewManager.UIAddChild(mGridContent.gameObject, mCellPrefab);
            }
            else
            {
                cell = value.cell.gameObject;
            }
            cell.name  = "CellPrefab";
            value.cell = cell.GetComponent <HS_UIListViewCell>();
            if (this.onInit != null)
            {
                this.onInit(this, value.cell, value.data);
            }
        }
示例#2
0
        private void CreateCell()
        {
            //Ex.Logger.Log("CreateCell", mCreateWithUpdate, Scheduler.GetTimer());
            Value      value = this.mValues[this.mKeepIndex];
            GameObject cell  = HS_ViewManager.UIAddChild(mGridContent.gameObject, mCellPrefab);

            cell.name = "CellPrefab";
            mValues[mKeepIndex].cell = cell.GetComponent <HS_UIListViewCell>();
            if (this.onInit != null)
            {
                this.onInit(this, value.cell, value.data);
            }
        }
示例#3
0
        public void UpdateLayout()
        {
            string gridCellPath = HS_Path.CombinePath("Assets", "SubAssets", "Res", "Prefabs", "UIListCell");

            if (mCellPrefab == null)
            {
                Debug.Log(mCellPrefabName);
                if (mCellPrefabName != "")
                {
                    string cellPrefabPath = HS_Path.CombinePath(gridCellPath, mCellPrefabName + ".prefab");
                    Debug.Log(cellPrefabPath);
                    GameObject prefab = UnityEditor.AssetDatabase.LoadAssetAtPath(cellPrefabPath, typeof(GameObject)) as GameObject;
                    mCellPrefab      = HS_ViewManager.UIAddChild(mGridContent.gameObject, prefab);
                    mCellPrefab.name = "CellPrefab";
                }
            }
            if (mGridContent == null)
            {
                Debug.LogError("Not specified GridContent");
                return;
            }
            if (mCellPrefab == null)
            {
                Debug.LogError("Not specified CellPrefab");
                return;
            }
            for (int i = mGridContent.transform.childCount - 1; i >= 0; i--)
            {
                Transform t = mGridContent.transform.GetChild(i);
                if (t.gameObject != mCellPrefab)
                {
                    DestroyImmediate(t.gameObject);
                }
            }
            int count = mCellCount - mGridContent.transform.childCount;

            for (int i = 0; i < count; i++)
            {
                GameObject cell = HS_ViewManager.UIAddChild(mGridContent.gameObject, mCellPrefab);
                cell.name = "Cell(clone)";
            }
        }