KaaPexei 发表于 2022-12-15 16:04

Unity手游截图功能

IEnumerator Capture(){      yield return new WaitForEndOfFrame();      int width = Screen.width;      int height = Screen.height;      Texture2D texture = new Texture2D(width,height,TextureFormat.RGB24,false);      Rect rect = new Rect(0, 0, width, height);      tex.ReadPixels(rect, 0, 0);      #if UNITY_ANDROID      texture.Apply();//不压缩      #elif UNITY_IPHONE      TextureScalePoint.ScalePoint (texture, width * 0.5, height * 0.5); //压缩      #endif      byte[] image = texture.EncodeToPNG();      File.WriteAllBytes(Application.persistentDataPath + "/" + "capture.png",image);//存储png图}
页: [1]
查看完整版本: Unity手游截图功能