AudioAsset
Ease
FastString
FontAsset
NineSlice
PackedSprite
PackedSpriteID
RB
   HardwareSettings
   IRetroBlitGame
RBAsset
Rect2i
ShaderAsset
SoundReference
SpriteGrid
SpriteSheetAsset
TMXMapAsset
   TMXLayer
   TMXLayerLoadState
   TMXObject
   TMXObjectGroup
   TMXProperties
Vector2i

RB.DisplaySurface

Property  -  Static Read Only

Type

Texture

Description

The RetroBlit display surface as a Texture. This texture can be used just like any other texture, and incorporated into any Unity Scene. For an example see the Old Days demo. This property is only useful if you want to handle your own rendering of the RetroBlit display surface in a custom way, or if you want to get at the pixel data.

Example

// Unity does not allow for conversion between Texture and Texture2D.
// This utility method will do that for us.
Texture2D TextureToTexture2D(Texture texture)
{
    Texture2D texture2D = new Texture2D(texture.width, texture.height, TextureFormat.RGBA32, false);

    RenderTexture currentRenderTexture = RenderTexture.active;

    RenderTexture renderTexture = new RenderTexture(texture.width, texture.height, 32);
    Graphics.Blit(texture, renderTexture);

    RenderTexture.active = renderTexture;
    texture2D.ReadPixels(new Rect(00, renderTexture.width, renderTexture.height), 00);
    texture2D.Apply();

    RenderTexture.active = currentRenderTexture;

    return texture2D;
}

// Capture a screenshot and save it to the given filename
void CaptureScreenshot(string filename)
{
    var tex = TextureToTexture2D(RB.DisplaySurface);
    var pngBytes = tex.EncodeToPNG();

    System.IO.File.WriteAllBytes(filename, pngBytes);
}

See Docs

Features - Taking Over the Display