private void InitAllTiles(int row, int col) { Debug.Log("[MyTilesScript] [InitAllTiles] row:" + row + " col:" + col); List <Transform> allTiles = new List <Transform>(); List <int> indexList = MJHelper.GenerateForFirstChoose(13); // GridLayoutGroup gridLayoutGroup = GetComponent<GridLayoutGroup>(); // gridLayoutGroup.constraint = GridLayoutGroup.Constraint.FixedRowCount; // gridLayoutGroup.constraintCount = row; indexList.Sort(); for (int i = 0; i < indexList.Count; i++) { if (CreateMahjongByValue(indexList[i]) == false) { break; } } }
private void InitAllTiles(int row, int col) { Debug.Log("[InitAllTiles] row:" + row + " col:" + col); List <Transform> allTiles = new List <Transform>(); List <int> indexList = MJHelper.GenerateForFirstChoose(row * col); GridLayoutGroup gridLayoutGroup = GetComponent <GridLayoutGroup>(); gridLayoutGroup.constraint = GridLayoutGroup.Constraint.Flexible; // gridLayoutGroup.constraintCount = row; for (int i = 0; i < indexList.Count; i++) { GameObject newCell = Instantiate <GameObject>(mahjongPrefab) as GameObject; Mahjong mahjong = newCell.GetComponent <Mahjong>() as Mahjong; mahjong.SetMahjongValue(indexList[i]); mahjong.SetStatus(Mahjong.Status.Selecting); // mahjong.SetStatus(Mahjong.Status.Closed); newCell.transform.SetParent(this.gameObject.transform, false); } }