UI/GlyphImagePanel.razor

A small Razor UI component that displays a glyph image. It sets an Image texture by calling Input.GetGlyph with ExpectedGlyphName unless the name is empty, and exposes ExpectedGlyphName as a property. BuildHash includes ExpectedGlyphName and Time.Now to force rebuilds frequently.

Networking
🐞 BuildHash includes Time.Now so the hash changes every frame and the panel rebuilds continuously.
@using Sandbox;
@using Sandbox.UI;
@inherits PanelComponent
@namespace Sandbox

<root>
	<Image Texture="@(ExpectedGlyphName == String.Empty?null:Input.GetGlyph( ExpectedGlyphName, InputGlyphSize.Medium, true ))"></Image>
</root>

@code
{
	[Property] public string ExpectedGlyphName { get; set; } = "";
	// https://stackoverflow.com/questions/263191/in-c-should-i-use-string-empty-or-string-empty-or-to-intitialize-a-string

	/// <summary>
	/// the hash determines if the system should be rebuilt. If it changes, it will be rebuilt
	/// </summary>
	protected override int BuildHash() => System.HashCode.Combine( ExpectedGlyphName, Time.Now );
}