Guest User

Untitled

a guest
May 24th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #region BIG EYE ROAD
  2. //COLUMN
  3. int prevSum = -1;
  4. for (int col = 0; col < table.GetLength(0); ++col)
  5. {
  6. GameObject p = Instantiate(big_eye_gameobject) as GameObject;
  7. p.transform.SetParent(pos_big_eye_road);
  8. p.transform.localScale = Vector3.one;
  9.  
  10. img = (RawImage)p.GetComponent<RawImage>();
  11.  
  12. int sum = CountRow(table, col);
  13.  
  14. Debug.Log("How many are there : " + CountRow(table, col));
  15. //Debug.Log("table column :" + col + " has " + sum + " data");
  16. if (sum == prevSum)
  17. {
  18. if (StartingPos == 1)
  19. {
  20. BigEyeYIndex = 0;
  21. BigEyeXIndex = 0;
  22. StartingPos++;
  23. }
  24. else
  25. {
  26. BigEyeYIndex += 1;
  27. }
  28.  
  29. img.texture = NewTexture[1];
  30. p.SetActive(true);
  31. //Debug.Log(col + " has the same length data as " + (col - 1));
  32. }
  33. else
  34. {
  35. BigEyeXIndex += 1;
  36. BigEyeYIndex = 0;
  37. img.texture = NewTexture[0];
  38. p.SetActive(true);
  39. }
  40. prevSum = sum;
  41.  
  42. p.transform.localPosition = new Vector3(BigEyeXIndex * 56, BigEyeYIndex * -45, 0f);
  43. }
  44. #endregion
  45. yield return null;
  46.  
  47. }
  48. //generic function
  49. public static int CountRow<T>(T[,] table, int col)
  50. {
  51. if (table == null || col < 0 || col >= table.GetLength(1))
  52. {
  53. //handle error
  54. return -1;
  55. }
  56.  
  57. //this is the same as the block of the outer for loop
  58. int sum = 0;
  59. for (int row = 0; row < table.GetLength(1); row++)
  60. {
  61. if(table[col,row] != null)
  62. {
  63. sum++;
  64. }
  65. }
  66. return sum;
  67. }
Add Comment
Please, Sign In to add comment