- Home /
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++;
}
}
Do you have a code fragment for your creation of the windows?
Answer by Berenger · May 06, 2012 at 05:56 AM
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.
been struggling with a simmiler problem for DAYS!!!! thanks Berenger, this fix was exactly what i needed! have a thumbs up.
Your answer
Follow this Question
Related Questions
GUI Window on GameObject location? 1 Answer
Stop clicking through a GUI window 2 Answers
GUI Window problem 2 Answers
Don't show window close button 1 Answer
GUI.Window only shows for one frame under all circumstances 2 Answers