Exemple #1
0
    //Will be called by the TableView when a cell needs to be created for display
    public TableViewCell GetCellForRowInTableView(TableView tableView, int row)
    {
        UICellBase cell = tableView.GetReusableCell(cellPrefab.reuseIdentifier) as UICellBase;

        if (cell == null)
        {
            cell      = (UICellBase)GameObject.Instantiate(cellPrefab);
            cell.name = "UICellBase" + (++numInstancesCreated).ToString();
            Rect    rccell      = (cellPrefab.transform as RectTransform).rect;
            Rect    rctable     = (tableView.transform as RectTransform).rect;
            Vector2 sizeCell    = (cellPrefab.transform as RectTransform).sizeDelta;
            Vector2 sizeTable   = (tableView.transform as RectTransform).sizeDelta;
            Vector2 sizeCellNew = sizeCell;
            sizeCellNew.x = rctable.width;

            AddCellItem(cell, tableView, row);
        }
        cell.totalItem = totalItem;
        if (oneCellNum != cell.oneCellNum)
        {
            //relayout
            cell.ClearAllItem();
            AddCellItem(cell, tableView, row);
        }
        cell.oneCellNum = oneCellNum;
        cell.rowIndex   = row;
        cell.UpdateItem(listItem);
        return(cell);
    }
Exemple #2
0
 void LoadPrefab()
 {
     {
         GameObject obj = PrefabCache.main.Load(AppCommon.PREFAB_UICELLBASE);
         cellPrefab = obj.GetComponent <UICellBase>();
     }
     {
         GameObject obj = PrefabCache.main.Load(AppCommon.PREFAB_UILanguageCellItem);
         cellItemPrefab = obj.GetComponent <UICellItemBase>();
     }
 }
 void LoadPrefab()
 {
     {
         GameObject obj = PrefabCache.main.Load(AppCommon.PREFAB_UICELLBASE);
         cellPrefab = obj.GetComponent <UICellBase>();
     }
     {
         GameObject obj = PrefabCache.main.Load("AppCommon/Prefab/Home/UILearnProgressCellItem");
         cellItemPrefab = obj.GetComponent <UICellItemBase>();
     }
 }
Exemple #4
0
 void LoadPrefab()
 {
     {
         GameObject obj = PrefabCache.main.Load(AppCommon.PREFAB_UICELLBASE);
         cellPrefab = obj.GetComponent <UICellBase>();
     }
     {
         GameObject obj = PrefabCache.main.Load("Common/Prefab/Comment/UICommentCellItem");
         cellItemPrefab = obj.GetComponent <UICellItemBase>();
     }
 }
Exemple #5
0
 void LoadPrefab()
 {
     {
         GameObject obj = PrefabCache.main.Load(AppCommon.PREFAB_UICELLBASE);
         cellPrefab = obj.GetComponent <UICellBase>();
     }
     // {
     //     GameObject obj = PrefabCache.main.Load(AppCommon.PREFAB_PLACE_CELL_ITEM_APP);
     //     cellItemPrefab = obj.GetComponent<UICellItemBase>();
     // }
 }
 void LoadPrefab()
 {
     {
         GameObject obj = PrefabCache.main.Load(AppCommon.PREFAB_UICELLBASE);
         cellPrefab = obj.GetComponent <UICellBase>();
     }
     {
         GameObject obj = PrefabCache.main.Load(AppCommon.PREFAB_PLACE_CELL_ITEM_APP);
         if (obj == null)
         {
             obj = PrefabCache.main.Load(AppCommon.PREFAB_PLACE_CELL_ITEM_COMMON);
         }
         cellItemPrefab = obj.GetComponent <UICellItemBase>();
     }
 }
Exemple #7
0
    void LoadPrefab()
    {
        {
            GameObject obj = PrefabCache.main.Load(AppCommon.PREFAB_UICELLBASE);
            cellPrefab = obj.GetComponent <UICellBase>();
        }
        {
            GameObject obj = PrefabCache.main.Load("AppCommon/Prefab/MoreApp/UIMoreAppCellItem");
            if (obj == null)
            {
                obj = PrefabCache.main.Load(AppCommon.PREFAB_MOREAPP_CELL_ITEM);
            }


            cellItemPrefab = obj.GetComponent <UICellItemBase>();
        }
    }
    //Will be called by the TableView when a cell needs to be created for display
    public TableViewCell GetCellForRowInTableView(TableView tableView, int row)
    {
        UICellBase cell = tableView.GetReusableCell(cellPrefab.reuseIdentifier) as UICellBase;

        if (cell == null)
        {
            cell      = (UICellBase)GameObject.Instantiate(cellPrefab);
            cell.name = "UICellBase" + (++numInstancesCreated).ToString();
            Rect    rccell      = (cellPrefab.transform as RectTransform).rect;
            Rect    rctable     = (tableView.transform as RectTransform).rect;
            Vector2 sizeCell    = (cellPrefab.transform as RectTransform).sizeDelta;
            Vector2 sizeTable   = (tableView.transform as RectTransform).sizeDelta;
            Vector2 sizeCellNew = sizeCell;
            sizeCellNew.x = rctable.width;

            for (int i = 0; i < oneCellNum; i++)
            {
                int            itemIndex  = row * oneCellNum + i;
                float          cell_space = 10;
                UICellItemBase item       = (UICellItemBase)GameObject.Instantiate(cellItemPrefab);
                //item.itemDelegate = this;
                Rect rcItem = (item.transform as RectTransform).rect;
                item.width  = (rctable.width - cell_space * (oneCellNum - 1)) / oneCellNum;
                item.height = heightCell;
                item.transform.SetParent(cell.transform, false);
                item.index         = itemIndex;
                item.totalItem     = totalItem;
                item.callbackClick = OnCellItemDidClick;

                cell.AddItem(item);
            }
        }
        cell.totalItem  = totalItem;
        cell.oneCellNum = oneCellNum;
        cell.rowIndex   = row;
        foreach (UICellItemBase it_base in cell.listItem)
        {
            UILearnProgressCellItem ui = it_base as UILearnProgressCellItem;
            ui.SetItemType(itemType);
            ui.colorSel   = colorSel;
            ui.colorUnSel = colorUnSel;
        }
        cell.UpdateItem(listItem);
        return(cell);
    }
    //Will be called by the TableView when a cell needs to be created for display

    public TableViewCell GetCellForRowInTableView(TableView tableView, int row)
    {
        UICellBase cell = tableView.GetReusableCell(cellPrefab.reuseIdentifier) as UICellBase;

        if (cell == null)
        {
            cell      = (UICellBase)GameObject.Instantiate(cellPrefab);
            cell.name = "UICellBase" + (++numInstancesCreated).ToString();
            Rect    rccell      = (cellPrefab.transform as RectTransform).rect;
            Rect    rctable     = (tableView.transform as RectTransform).rect;
            Vector2 sizeCell    = (cellPrefab.transform as RectTransform).sizeDelta;
            Vector2 sizeTable   = (tableView.transform as RectTransform).sizeDelta;
            Vector2 sizeCellNew = sizeCell;
            sizeCellNew.x = rctable.width;

            //  cell.SetCellSize(sizeCellNew);

            // Debug.LogFormat("TableView Cell Add Item:rcell:{0}, sizeCell:{1},rctable:{2},sizeTable:{3}", rccell, sizeCell, rctable, sizeTable);
            // oneCellNum = (int)(rctable.width / heightCell);
            //int i =0;
            for (int i = 0; i < oneCellNum; i++)
            {
                int            itemIndex  = row * oneCellNum + i;
                float          cell_space = 10;
                UICellItemBase item       = (UICellItemBase)GameObject.Instantiate(cellItemPrefab);
                //item.itemDelegate = this;
                Rect rcItem = (item.transform as RectTransform).rect;
                item.width  = (rctable.width - cell_space * (oneCellNum - 1)) / oneCellNum;
                item.height = heightCell;
                item.transform.SetParent(cell.transform, false);
                item.index         = itemIndex;
                item.totalItem     = totalItem;
                item.callbackClick = OnCellItemDidClick;

                cell.AddItem(item);
            }
        }
        cell.totalItem  = totalItem;
        cell.oneCellNum = oneCellNum;
        cell.rowIndex   = row;
        cell.UpdateItem(listItem);
        return(cell);
    }
Exemple #10
0
    void AddCellItem(UICellBase cell, TableView tableView, int row)
    {
        Rect rctable = (tableView.transform as RectTransform).rect;

        for (int i = 0; i < oneCellNum; i++)
        {
            int            itemIndex  = row * oneCellNum + i;
            float          cell_space = 10;
            UICellItemBase item       = (UICellItemBase)GameObject.Instantiate(cellItemPrefab);
            //item.itemDelegate = this;
            Rect rcItem = (item.transform as RectTransform).rect;
            item.width  = (rctable.width - cell_space * (oneCellNum - 1)) / oneCellNum;
            item.height = heightCell;
            item.transform.SetParent(cell.transform, false);
            item.index         = itemIndex;
            item.totalItem     = totalItem;
            item.callbackClick = OnCellItemDidClick;

            cell.AddItem(item);
        }
    }