Please I need help with this i have been able to take a screenshot i just need to save it into a folder of the android device(gallery documents…anyone).I have researched this but can’t seem to find a working solution.Would really appreciate any help i can get with this.
My current code is pasted below
import System.IO;
var explosion:GameObject[];
var dec:GUITexture;
var levelToLoad:String;
// increment our filename
private var count:int = 0;
/**
* Test key
*/
function Update()
{
}
//Take the screen buffer and spit out a JPG
function ScreenshotEncode()
{
// wait for graphics to render
yield WaitForEndOfFrame();
// create a texture to pass to encoding
var texture:Texture2D = new Texture2D (Screen.width, Screen.height, TextureFormat.RGB24, false);
// put buffer into texture
texture.ReadPixels(Rect(0.0, 0.0, Screen.width, Screen.height), 0.0, 0.0);
texture.Apply();
// split the process up--ReadPixels() and the GetPixels() call inside of the encoder are both pretty heavy
yield;
// create our encoder for this texture
var encoder:JPGEncoder = new JPGEncoder(texture, 75.0);
// encoder is threaded; wait for it to finish
while(!encoder.isDone)
yield;
// save our test image (could also upload to WWW)
File.WriteAllBytes(Application.persistentDataPath + "/../MyTree-" + count + ".jpg", encoder.GetBytes());
yield WaitForSeconds(1);
//play sound here
//System.Diagnostics.Process.Start("mspaint.exe","MyTree-" + count + ".jpg");
count++;
guiTexture.enabled=true;
dec.guiTexture.enabled=true;;
Application.LoadLevel(levelToLoad);
}
function OnMouseDown(){
Destroy(GameObject.FindWithTag("chickens"));
Destroy(GameObject.FindWithTag("pal"));
guiTexture.enabled=false;
dec.guiTexture.enabled=false;
Instantiate(explosion[Random.Range(0,explosion.Length)]);;
yield WaitForSeconds(2);
ScreenshotEncode();
}