Click or drag to resize

GuiEnabledStateScope Class

A utility class to render a big disabled block in GUI.
Inheritance Hierarchy
SystemObject
  KSPDev.GUIUtilsGuiEnabledStateScope

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

The GuiEnabledStateScope type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleGuiEnabledStateScope
Stores the old state and sets a new one.
Top
Methods
  NameDescription
Public methodDispose
Restores the enabled state that was set before the scope started.
Top
Examples
void OnGUI() {
  GUI.enabled = true;
  using (new GuiEnabledStateScope(false)) {
    // All the controls in this block will become disabled.
    GUILayout.Button("Disabled button 1");
    GUILayout.Button("Disabled button 2");
  }
  // From here the enabled state is True again.
  GUILayout.Button("Enabled button 3");
}
See Also