Take screenshots while game is playing

Hi all,
I am new in Android development. I try to code in JS a script to take a screenshot while the game is playing, but it does not work for me. After a long research over Google I have followed this steps:

  1. File> Build Settings> Player Settings…> Other Settings> Configuration> Write Access> External (SD Card)
  2. Create some game object + GUI Text
  3. Main Camera, I attached the script:

#pragma strict

// For Android Devices ONLY
// Attach this script to Main Camera

// File> Build Settings> Player Settings…> Other Settings> Configuration> Write Access> External (SD Card),
// this setup will create inside Android Device using Windows 7 → Phone/Android/data/com.Company.LuceDigitale
// It this equal the write inside AndroidManifest.xml →

var scoreTextX : GUIText;
var localize : String;

function Start() {
}

function OnGUI()
{
if (GUI.Button(Rect(10,10,200,50),“Capture Screenshot”))
{
// debug data path
localize = Application.persistentDataPath;
scoreTextX.text = localize;
// it writes: /storage/sdcard0/Android/data//files folder

// We should only read the screen buffer after rendering is complete
yield WaitForEndOfFrame();

// static function CaptureScreenshot(filename: string, superSize: int = 0): void;
Application.CaptureScreenshot(“Screenshot.png”);
}
}

  1. Build the .apk and copy and paste inside my Samsung S2 connected as multimedia device
  2. I have installed the .apk and run it.
  3. If I will press the button the GUI text is /storage/sdcard0/Android/data//files folder
  4. With Windows I browsed the Phone and I found the folder:
    Phone/Android/data/com.Company.LuceDigitale/cache
    There is not files folder and there is not Screenshot.png :cry:

Every help would be appreciated :smile:

Hi if you are planning to post the screenshots directly to user’s facebook account then I think you should use Android Native Plugin. It is very useful and easy to integrate. And maybe from that you can deduce how to take screen shots ONLY and not post them on facebook, Cheers :slight_smile:

Thanks tobicreaper! I’d like to save the image inside the Android Device, but I will try Android Native Plugin for sure! It seems a good software! Have a nice day! :slight_smile: