- Home /
Question by
avadoto · Dec 03, 2016 at 09:39 AM ·
androidcamerascreenshotsave-to-file
Cant find where the screenshots are saved or if they are even taken
heres the script
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using System.IO;
public class scene2 : MonoBehaviour
{
private int Screen_Shot_Count = 0;
private bool Shot_Taken = false;
private string screenshot;
WebCamTexture webcamTexture = new WebCamTexture(); // Plane gets camera texture
public GameObject plane;
public Texture2D back;
public int activeButton = 1;
void Start()
{
Renderer renderer = plane.GetComponent<Renderer>();
renderer.material.mainTexture = webcamTexture;
plane.SetActive(false);
}
void Update()
{
}
void OnGUI()
{
if (activeButton == 1)
{
if (GUI.Button(new Rect(0, 740, 60, 60), back))
{
SceneManager.LoadScene(0);
}
if (GUI.Button(new Rect(420, 740, 60, 60), "camera"))
{
plane.SetActive(true);
activeButton = 2;
{
webcamTexture.Play();
}
}
}
if (activeButton == 2)
{
if (GUI.Button(new Rect(420, 740, 60, 60), "atgal")) //back button when camera is active
{
webcamTexture.Stop();
activeButton = 1;
{
plane.SetActive(false);
}
}
if (GUI.Button(new Rect(420, 360, 60, 60), "photo"))
{
Screen_Shot_Count++;
screenshot = "Screenshot__" + Screen_Shot_Count + System.DateTime.Now.ToString("__yyyy-MM-dd") + ".png";
Application.CaptureScreenshot(screenshot);
Shot_Taken = true;
Debug.LogError("works123"); //works on pc
}
if (Shot_Taken == true)
{
string Origin_Path = System.IO.Path.Combine(Application.persistentDataPath, screenshot);
// This is the path of my folder.
string Path = "/storage/emulated/0/Calculator/" + screenshot;
if (File.Exists(Origin_Path))
{
File.Move(Origin_Path, Path);
Shot_Taken = false;
}
}
}
}
}
everything seem to work ,even when i press ''photo'' button to take screenshot, it lags for half a second as if it was taking screenshot ,but it just doesnt appear anywhere.Maybe someone know what might be the problem? i am also using plane to render live input from camera. heres 2 pictures so maybe its easier to imagine what this script looks like: http://imgur.com/a/YaDsz ,i used this post as an example http://answers.unity3d.com/questions/845836/saving-path-for-screenshot.html
Comment
Best Answer
Answer by avadoto · Dec 04, 2016 at 05:00 PM
if someone else cant find where screenshots are being saved go to Edit>Project settings>Player>Other settings>write access and select External(sd card)