Hello All,
Trying to make my app work here, I manage to make my app take picture using my Android devices, after taking picture the picture will be stored into specific folder that been created. But the problem right now is how do I let the picture that I’ve taken can be seen from Android Gallery.
Below here is what I’ve done so far:
using UnityEngine;
using System.Collections;
using System.IO;
public class CameraFunction : MonoBehaviour {
public int screenShotCount;
public string screenShotFileName = "";
public string transfer = "";
public string transfer2 = "";
public RaycastHit hit;
public Camera guiCam;
public bool pressed;
// Use this for initialization
void Start ()
{
if (!System.IO.Directory.Exists ("mnt/sdcard/DCIM/UISCREENSHOT/"))
{
System.IO.Directory.CreateDirectory ("mnt/sdcard/DCIM/UISCREENSHOT/");
}
}
// Update is called once per frame
void LateUpdate ()
{
var ray = guiCam.ScreenPointToRay (Input.mousePosition);
if (Input.GetMouseButtonUp (0)) //Returns true during the frame the user touches the object
{
if (Physics.Raycast (ray, out hit, 100))
{
if (hit.collider.tag == "camera")
{
pressed = true;
do
{
screenShotCount++;
screenShotFileName = "UIscreenShot" + screenShotCount + ".png";
}
while (System.IO.File.Exists (screenShotFileName));
Application.CaptureScreenshot (screenShotFileName);
}
}
}
transfer = "mnt/sdcard/Android/data/com.LCGDI.ARKARNIVAL2015/files/" + screenShotFileName;
transfer2 = "mnt/sdcard/DCIM/UISCREENSHOT/" + screenShotFileName;
System.IO.File.Move (transfer, transfer2);
}
}