For loops in OnGUI function??

Hi, I want to create a screen resolution selector in the GUI using a for loop, but the for loop only shows the first execution in the bucle, it not repeats....

The code:

function WindowOptions()


GUI.Label (Rect (50,40,100,20), "Resolucin:", "options");
// Resoluciones disponibles 

GUI.Box (Rect (50,70,100,200),"");
GUILayout.BeginArea (Rect (50,70,100,200));

var resolutions : Resolution[] = Screen.resolutions;

for (var res in resolutions)
	if (GUILayout.Button (res.width + "x" + res.height))
	changedResWidth = res.width;
	changedResHeight = res.height;



GUI.Label (Rect (225,40,150,20), "Nivel de detalle:", "options");


I think it is because the loop are in the OnGUI function... so, any way to make the for loop in Update fuction and create the buttons (one for each resoluton) in the OnGUI function??

Sorry for my Span-glish and thanks a lot. ;)

Are you calling this every frame in OnGUI? Because OnGUI is not persistent and needs to be redrawn every frame. There isn't any problem with for loops in OnGUI; it wouldn't be very usable if you couldn't code as usual in it. In the editor, only 640x480 will show up when using Screen.resolutions.