S&box Wiki

Revision Difference

making_a_custom_pause_screen#562452

<title>Making a Custom Pause Screen</title> <cat>UI.GameMenu</cat>⤶ # Overriding s&box's default pause menu By default, s&box gives every game a default pause menu, this lets people rebind and change settings even when the developer themselves hasn't created a menu for it. <upload src="b3f81/8dcabad07975c95.png" size="68183" name="image.png" /> <note>Currently only Keybinds are able to changed with this pause menu</note> Not you though, or else you wouldn't be here. To override thie default menu put the following into your Update loop on whatever component handles turning the screen on and off ```cs // In Update() on one of your components if ( Input.EscapePressed ) { Input.EscapePressed = false; // handle escape pressed in your game } ``` An example would be ```cs public bool Pause; //This assumes your pause screen is as simple as turning a GameObject with a screen panel on and off [Property] public GameObject PausePanel {get; set;} protected override void OnUpdate() { if ( Input.EscapePressed ) { Input.EscapePressed = false; Pause != Pause; } if ( Pause == true ) { PauseMenu.Enabled = true; } else { PauseMenu.Enabled = false; } } ``` This is by no means the most *efficient* way to do this, but the verbosity should serve to help those that are less familiar with such means. If you wanted to use the default pause menu's Keybind Overlay, you can do so with ```html <div class="tab" @onclick="@(() => Game.Overlay.ShowBinds() )">Controls</div> ``` Same with the "About" screen ```html <div class="tab" @onclick="@(() => Game.Overlay.ShowPackageModal( [Indent Here ex: facepunch.test] ))">About</div> ```