S&box Wiki

Revision Difference

making_a_custom_pause_screen#562454

<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. ⤶ By default, s&box will show this pause menu when a player presses the ESC key in-game:⤶ <upload src="b3f81/8dcabb27923fbaa.png" size="19516" name="sbox_5iXD7x59uR.png" /> <note>Currently only Keybinds are able to changed with this pause menu</note>⤶ ⤶ Not you though, or else you wouldn't be here. This is an example of how to override it⤶ ⤶ This gives players the options expected of a pause menu so that the game's developer doesn't have to code them.⤶ ⤶ But if you're reading this, then maybe these options weren't enough. ⤶ So, here's how to override the default pause menu:⤶ ```cs //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; //The ESC Key is now yours to control, so you could do the following PausePanel.Enabled != PausePanel.Enabled; } } ``` ## Using in-built Overlays for your menu 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> ```