public void freshShopItem(int index, MDShopData data) { _index = index; if (leftCell == null) { leftCell = CShopScrollCellView.CreateItemCell(data); leftCell.transform.parent = this.transform; leftCell.transform.localPosition = new Vector3(0, 0, 0); leftCell.transform.localScale = Vector3.one; } else { leftCell.freshViewWithData(data); } }
public static CShopScrollCellView CreateItemCell(MDShopData sd) { Object mObj = null; if (sd.type == MDShopData.ITEM) { mObj = Resources.Load("shopItemCell"); } else if (sd.type == MDShopData.COIN) { mObj = Resources.Load("shopCoinCell"); } else if (sd.type == MDShopData.JEWEL) { mObj = Resources.Load("shopJewelCell"); } GameObject go = Instantiate(mObj) as GameObject; CShopScrollCellView cell = go.GetComponent <CShopScrollCellView>(); cell.freshViewWithData(sd); return(cell); }