A UI Razor component for the title screen. It displays a text div bound to MyStringValue and listens for the Jump input to load a configured SceneFile nextscene.
@using Sandbox;
@using Sandbox.UI;
@inherits PanelComponent
@namespace Sandbox
<root>
<div class="title">@MyStringValue</div>
</root>
@code
{
[Property] public SceneFile nextscene { get; set; }
[Property, TextArea] public string MyStringValue { get; set; } = "Press Space Key or A Button";
protected override void OnUpdate()
{
if (Input.Pressed("Jump"))
{
Scene.Load(nextscene);
}
}
/// <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( MyStringValue );
}