S&box Wiki

Revision Difference

Input_Glyphs#546539

<cat>Code.Misc</cat>⤶ <title>Input Glyphs</title>⤶ ⤶ Input glyphs are an easy way to show users which buttons to press for actions, they automatically adjust for whatever device you're using and return appropriate textures.⤶ ⤶ <upload src="a5727/8d9f1566df80255.png" size="396230" name="image.png" />⤶ ⤶ ```csharp⤶ Texture JumpButton = Input.GetGlyph( InputButton.Jump );⤶ ```⤶ ⤶ <note>You should set your UI image every tick with Input.GetGlyph, this is because the user can rebind keys or the input device can change part way through a game.</note>⤶ ⤶ # Styles⤶ ⤶ There's some different styles and style modifiers you can chain to get the right look for your UI.⤶ ⤶ * Knockout: the ABXY face buttons will have colored labels/outlines on a knocked out background.⤶ * Light: black detail/borders on a white background .⤶ * Dark: white detail/borders on a black background ⤶ ⤶ ## Modifiers⤶ ⤶ Modifiers ( Default ABXY/PS equivalent glyphs have a solid fill w/ color matching the physical buttons on the device )⤶ ⤶ * WithSolidABXY: ABXY Buttons will have a solid fill.⤶ * WithNeutralColorABXY: ABXY Buttons will match the base style color instead of their normal associated color.⤶ ⤶ ```csharp⤶ ImageGlyph.Texture = Input.GetGlyph( InputButton, InputGlyphSize.Small, GlyphStyle.Knockout.WithSolidABXY().WithNeutralColorABXY() );⤶ ```⤶ ⤶ <note>With neutral colored glyphs you can always use SCSS to tint the glyph colors to better suit your game's UI.</note>