Hiii everyone, I have the requirement of capturing screen shot, saving it and accessing to show it on screen. How can I do this? please help out this new bee… Thanks in advance
Hi,
You can use “Application.CaptureScreenshot” to capture Image in Unity.
you can refer the below link for reference.
public static string screenshotFilename = "screenshotName.png";
void Start() {
Application.CaptureScreenshot( screenshotName );
}
//use this to find the Path of the Image
var pathToImage = Application.persistentDataPath + "/" + screenshotName;
Try this out and post the result here.
Thanks
@tenthplanet0
Here is simple Code for capturing screen shot, and showing the captured image on screen
This Code is For Andriod and IPhone.For PC Just Give the Image Path
public RawImage image;
void Start()
{
Photo();
Invoke("GetPhoto",1f);
}
public void Photo()
{
Application.CaptureScreenshot(Variables.ImageName);
}
public void GetPhoto()
{
#if !UNITY_EDITOR
string url = Application.persistentDataPath +"/"+Variables.ImageName;
var bytes = File.ReadAllBytes( url );
Texture2D texture = new Texture2D( 73, 73 );
texture.LoadImage( bytes );
image.texture= texture ;
#endif
}