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:
- File> Build Settings> Player Settings…> Other Settings> Configuration> Write Access> External (SD Card)
- Create some game object + GUI Text
- 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”);
}
}
- Build the .apk and copy and paste inside my Samsung S2 connected as multimedia device
- I have installed the .apk and run it.
- If I will press the button the GUI text is /storage/sdcard0/Android/data//files folder
- 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
Every help would be appreciated