//从下往上遍历 得到每排最下空白处 和 最上空白处的距离 for (int x = 0; x < xColumn; x++) { //没障碍物的情况下 int min = 0; int max = yRow-1; for (int y = min; y <= max; y++) { GameSweet gameSweet = CreateNewSweet(x, y, SweetsType.NORMAL); gameSweet.ColoredComponent.SetColor((ColorSweet.ColorType)UnityEngine.Random.Range(0, gameSweet.ColoredComponent.NumColor)); } }