A GameObjectSystem for a pixel-screen renderer that keeps the last software frame (pixel array, display rect and camera background color) alive across a scene change so the incoming menu can fade it out. Exposes Remember to capture a PixelScreen and Release to drop the reference.
namespace Sandbox.Transposer;
/// <summary>
/// The platform's Leave action replaces the scene objects immediately. Keep the last
/// software frame in the scene system so the incoming menu can finish fading it out.
/// </summary>
public sealed class LastGameplayFrame( Scene scene ) : GameObjectSystem<LastGameplayFrame>( scene )
{
internal Color32[] Pixels { get; private set; }
internal Rect Bounds { get; private set; }
internal Color Background { get; private set; }
internal void Remember( PixelScreen screen )
{
// Scene changes leave this array intact. Gameplay can keep drawing into it until then.
Pixels = screen.GetPixelsWritable();
Bounds = screen.DisplayRect;
Background = Scene.Camera.BackgroundColor;
}
internal void Release() => Pixels = null;
}