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
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(0, 0, renderTexture.width, renderTexture.height), 0, 0); texture2D.Apply();
RenderTexture.active = currentRenderTexture;
return texture2D; }
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
|