CreateCells









How do I use Create Cells
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: Board.cs Copy
22         public void Init(Action onBoardChangeAction)
23         {
24             CreateCells();
25             SetPlayer(Seed.Empty);
26             onBoardChange = onBoardChangeAction;
27         }
File name: Board.cs Copy
128         private void CreateCells()
129         {
130             Transform container = (new GameObject("Cells")).transform;
131
132             container.transform.parent = transform;
133             container.transform.localPosition = new Vector3(-cellOffset, -cellOffset, 0f);
134
135             for (int row = 0; row < ROWS; row++)
136             {
137                 for (int col = 0; col < COLS; col++)
138                 {
139                     GameObject go = (GameObject)Instantiate(cellPrefab, Vector3.zero, Quaternion.identity);
140                     Cell cell = go.GetComponent();
141
142                     cell.transform.parent = container;
143                     cell.transform.localPosition = new Vector3(col * cellOffset, row * cellOffset, 0f);
144
145                     cell.Init(row, col, OnCellClick);
146
147                     cells[row, col] = cell;
148                 }
149             }
150         }

CreateCells 121 lượt xem

Gõ tìm kiếm nhanh...