Click or drag to resize

GuiWindow Class

A utility class to deal with the GUI windows.
Inheritance Hierarchy
SystemObject
  KSPDev.GUIUtilsGuiWindow

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.5 (in KSPDev_Utils.2.5.dll) Version: 2.5 for KSP v1
Syntax
C#
public static class GuiWindow
Request Example View Source

The GuiWindow type exposes the following members.

Methods
  NameDescription
Public methodStatic memberCode exampleDragWindow
Makes the window movable. It's an improved version of the stock GUI.DragWindow() method.
Top
Remarks
The stock window cancels dragging when the window layout is changed. It makes it useless when dealing with windows that can change their layout depending on the position. This method doesn't have this drawback. Moreover, it can tell if the window is being dragged, so that the code could postpone the layout update until the dragging is over.
Examples
public class GuiWindowDemo1 : MonoBehaviour {
  Rect windowRect;
  Rect titleBarRect = new Rect(0, 0, 10000, 20);

  void OnGUI() {
    windowRect = GUILayout.Window(12345, windowRect, WindowFunc, "Test title");
  }

  void WindowFunc(int windowId) {
    // ...add the controls....

    // Allow the window to be dragged by its title bar.
    GuiWindow.DragWindow(ref windowRect, titleBarRect);
  }
}
See Also