How to make multiple GUI window?

I’m looking for a way to make GUI windows where the number of windows are volatile.
I tried to set a for loop and assign GUI.window to a Rect array, but it only the first and the last window are dragable the rest are static.

I appreciate your responds,

The code:

void MakeWindows(){
	int windowIndex = 0;
	foreach (string name in objNames) {
		BeginWindows();
		windowRects[windowIndex] =  GUILayout.Window (windowIndex, windowRects[windowIndex], DoMyWindow, name);
		EndWindows();
		windowIndex++;
}
}

You should create a class for that purpose. It would contain the ID :

public class CustomWindows{
    int _id;
    public CustomWindows(){}
    public CustomWindows( int id ){ _id = id; }

    public Rect Draw( Rect R, WindowFunction func, string name )
    {
        return GUI.Window( _id, R, func, name );
    }
}

The trick here is to instantiate them with a different int for each one. Then in OnGUI, loop through them all and call Draw.