Slev
September 17, 2014, 3:49am
1
if (popup)
windowrect = GUI.ModalWindow (0, windowrect, PromptWindow, “Customize Maneuver”);
}
//Pop-up Window Fumctions
void PromptWindow(int windowid) {
GUILayout.BeginArea(new Rect(10,20,200,200));
GUILayout.Label("Enter degrees to move...");
angle = GUILayout.TextField(angle);
GUILayout.BeginHorizontal();
GUILayout.Button ("Confirm");
GUILayout.Button ("Cancel");
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
I’ve found that these don’t always error but seem to error more than not. Is it possible that the if statement (which is in OnGUI) is causing errors where some parts of the modal window are called but not the rest? If that is the case, how can I ensure that the full window function is fully called?
Don’t forget to close a modal window:
void OnGUI() {
if (popup)
windowrect = GUI.ModalWindow (0, windowrect, PromptWindow, "Customize Maneuver");
}
//Pop-up Window Fumctions
void PromptWindow(int windowid) {
GUILayout.BeginArea(new Rect(10,20,200,200));
GUILayout.Label("Enter degrees to move...");
angle = GUILayout.TextField(angle);
GUILayout.BeginHorizontal();
GUILayout.Button ("Confirm");
if (GUILayout.Button ("Cancel")) {
popup = false; //close modal window
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
But you remember if at you in one frame it is drawn two or more modal windows, it will cause an error. For example:
void OnGUI() {
if (popup)
windowrect = GUI.ModalWindow (0, windowrect, PromptWindow, "Customize Maneuver");
//Some popup2 and other variable
if (popup2)
windowrect2 = GUI.ModalWindow (0, windowrect2, PromptWindow2, "Customize Maneuver");
}
This code call error, because in one frame two modal window is caused. In one frame must be one modal window. I hope that it will help you.