Using System.IO;
Get the system time and name the photo name
System.DateTime now = System.DateTime.Now;
String times = Now. ToString ();
Times = times. Trim ();
Times = times. Replace ("/", "-");
Filename
string filename = "screenshot" +times+ ". png";
Determine if the Android platform
if (Application.platform = = runtimeplatform.android) {
Capture Screen
Texture2d texture = new Texture2d (Screen.width, Screen.height, Textureformat.rgb24, false);
Texture. Readpixels (New Rect (0, 0, Screen.width, screen.height), 0, 0);
Texture. Apply ();
Convert to byte array
byte[] bytes = texture. Encodetopng ();
String destination = "/sdcard/dcim/arphoto";
Determines whether the directory exists, does not exist, and creates a directory
if (! Directory.Exists (destination)) {
Directory.CreateDirectory (destination);
}
File path
String path_save = destination+ "/" + filename;
Save picture
System.IO.File.WriteAllBytes (Path_save, bytes);
}
Unity release Android saved to local