Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region BIG EYE ROAD
- //COLUMN
- int prevSum = -1;
- for (int col = 0; col < table.GetLength(0); ++col)
- {
- GameObject p = Instantiate(big_eye_gameobject) as GameObject;
- p.transform.SetParent(pos_big_eye_road);
- p.transform.localScale = Vector3.one;
- img = (RawImage)p.GetComponent<RawImage>();
- int sum = CountRow(table, col);
- Debug.Log("How many are there : " + CountRow(table, col));
- //Debug.Log("table column :" + col + " has " + sum + " data");
- if (sum == prevSum)
- {
- if (StartingPos == 1)
- {
- BigEyeYIndex = 0;
- BigEyeXIndex = 0;
- StartingPos++;
- }
- else
- {
- BigEyeYIndex += 1;
- }
- img.texture = NewTexture[1];
- p.SetActive(true);
- //Debug.Log(col + " has the same length data as " + (col - 1));
- }
- else
- {
- BigEyeXIndex += 1;
- BigEyeYIndex = 0;
- img.texture = NewTexture[0];
- p.SetActive(true);
- }
- prevSum = sum;
- p.transform.localPosition = new Vector3(BigEyeXIndex * 56, BigEyeYIndex * -45, 0f);
- }
- #endregion
- yield return null;
- }
- //generic function
- public static int CountRow<T>(T[,] table, int col)
- {
- if (table == null || col < 0 || col >= table.GetLength(1))
- {
- //handle error
- return -1;
- }
- //this is the same as the block of the outer for loop
- int sum = 0;
- for (int row = 0; row < table.GetLength(1); row++)
- {
- if(table[col,row] != null)
- {
- sum++;
- }
- }
- return sum;
- }
Add Comment
Please, Sign In to add comment