Hi I want to use a part of this script here.
function UploadPNG () {
// We should only read the screen bufferafter rendering is complete
yield WaitForEndOfFrame();
// Create a texture the size of the screen, RGB24 format
var width = Screen.width;
var height = Screen.height;
var tex = new Texture2D (width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels (Rect(0, 0, width, height), 0, 0);
tex.Apply ();
// Encode texture into PNG
var bytes = tex.EncodeToPNG();
Destroy (tex);
// For testing purposes, also write to a file in the project folder
// File.WriteAllBytes(Application.dataPath + "/../SavedScreen.png", bytes);
The lines wich interessed me are :
var bytes = tex.EncodeToPNG();
and
File.WriteAllBytes(Application.dataPath + "/../SavedScreen.png", bytes);
What is the var bytes in C#? I don’t understand what does that represent.
My goal here is to read a Texture2D and save it with a “File.WriteAllBytes” or any other functions which allows me to set the path like here.
All of this is done localy not online.
This is kind of urgent I hope someone can help me quickly
Thank’s a lot
BooBi