Okay, so what I’m trying to do with the below code is generate a 4x4 grid of colored buttons that is generated from an array. I don’t think I can use the SelectionGrid function for this case, because I can’t change the color of the buttons. (It’s a window function so it’s called from the GUI function.) However, when I run the code, it crashes Unity. Why is this?
void SavedColorsPanel (int windowID) {
int i = 0;
Color curGuiColor = GUI.backgroundColor;
for(int x = 0;x<4;x++) {
for(int y = 0;y<4;x++) {
if(i<sceneColors.Count) {
GUI.backgroundColor = sceneColors*;*
_ GUI.Button(new Rect( y20+10, x20+10, 25, 20), “”);_
-
i++;*
-
} else {*
-
GUI.backgroundColor = Color.white;*
_ GUI.Button(new Rect( y20+10, x20+10, 25, 20), “”);_
-
}*
-
}*
-
}*
-
GUI.backgroundColor = curGuiColor;*
-
GUI.DragWindow();*
- }*