A scene component that, when present on a scene, prevents a StartMenu instance from pausing the game timescale. It tries to find a GameObject named "ScreenMenu" and obtain its StartMenu component, or uses a serialized property if provided, then sets PlsDoNotFreeze = true on it.
using Sandbox;
public sealed class DoNotFreezeOnPause : Component, ISceneProperties
{
// add this component to scene to be detected.
// when it found, StartMenu won't timescale
[Property] protected StartMenu? theMenu { get; set; }
protected override void OnStart()
{
if(!theMenu.IsValid())
{
try{
GameObject? findThe = Scene.Directory.FindByName( "ScreenMenu" ).First();
// theMenu = Scene.Directory.FindByName( "ScreenMenu" ).First().GetComponent<StartMenu>();
if(findThe.IsValid()) theMenu = findThe.GetComponent<StartMenu>();
} catch (Exception e)
{
}
}
if ( theMenu.IsValid() )
{
theMenu.PlsDoNotFreeze = true;
}
}
protected override void OnUpdate()
{
}
}