[csharp]
view plain
copy
print
?
System.DateTime now = System.DateTime.Now; string times = now.ToString (); times = times.Trim (); times = times.Replace ("/","-"); string filename = "Screenshot"+times+".png"; if (Application.platform == RuntimePlatform.Android) { 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(); byte[] bytes = texture.EncodeToPNG(); string destination = "/sdcard/DCIM/ARphoto"; if (!Directory.Exists (destination)) { Directory.CreateDirectory (destination); } Path_save = destination+"/" + filename; System.IO.File.WriteAllBytes(Path_save, bytes); }
注意,PlayerSetting这里的设置,改为SDCard。
转载请注明原文地址: https://ju.6miu.com/read-968883.html