- Home /
[ANDROID]How to load images from a certain folder after a screenshot?
Friends, let's move! Question ANDROID! I have a problem. If there is a solution, everyone will benefit
Counted after 3 seconds, I can do a print screen of the game and also save this image on your device> Android / data / com.xxx.xxx / File / screenshot.png file
IS A SUCCESS!
My problem is: HOW TO VIEW THIS PICTURE AFTER THE SCREENSHOT?
MY SCRIPT:
using UnityEngine;
using System.Collections;
public class ScreenShotANDPrint : MonoBehaviour {
public float time = 3; // Set your time.
public GameObject screenshotImage; // Set your image(Sprite Renderer, etc,...).
public int NumberStage;
public string url = "jar:file://" + Application.dataPath + "/assets/" + "/Screenshot.png";
public Texture2D texturas;
void Start(){
screenshotImage.active = false;
WWW www = new WWW("jar:file://" + Application.dataPath + "/assets/" + "/Screenshot.png");
StartCoroutine(registerFunc(www));
}
//DEBUGA O "ERROR LINHA 34"
IEnumerator registerFunc(WWW www)
{
yield return www;
if (www.error == null)
{
Debug.Log("OK - CountTime");
texturas = www.texture;
}
else
{
Debug.Log("ERROR");
}
}
void Update () {
//Application.CaptureScreenshot(Application.persistentDataPath+"/Frame.png");
//Application.CaptureScreenshot("Screenshot.png");
time -= Time.deltaTime;
int myInt = (int)time;
}
void OnGUI(){
WWW www = new WWW (url);
WWW loadingImageWWW = new WWW("jar:file://" + Application.dataPath + "/assets/" + "/Screenshot.png");
int myInt = (int)time;
GUI.Box(new Rect(Screen.width/2,Screen.height/2,100,25),myInt.ToString());
if(myInt == 0 )
{
time = 0;
//This is obsolete, but it works.
screenshotImage.active = true;
//Aqui ele bate a foto da tela
Application.CaptureScreenshot("Screenshot.png");
if (loadingImageWWW.isDone)
{
/ / Here my textures should appear, but they appear as a white box and a red mark.
GUI.Button(new Rect(Screen.width/2 - 30,Screen.height/3,165, 30),loadingImageWWW.texture);
GUI.DrawTexture(new Rect(300,0,100,100),www.texture);
GUI.DrawTexture(new Rect(300,100,100,100),loadingImageWWW.texture);
}
if(GUI.Button(new Rect(Screen.width/2 - 30,Screen.height/3,165, 30),url)){
Application.LoadLevel(NumberStage);
}
}
}
}
Answer by Oribow · May 02, 2014 at 07:39 PM
Take a look here. "How to make and save an Android Screenshot First, according to this post, androids have problems encoding to PNG. This post provided a link to an alternative jpg encoding.
Second, to view the screenshot from the android file manager, the file path needs to be set using Application.persistentDataPath . More in this post."
Accept if it helps you.