找回密码
 立即注册
查看: 216|回复: 0

Unity手游截图功能

[复制链接]
发表于 2022-12-15 16:04 | 显示全部楼层 |阅读模式
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图}
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-11-15 22:48 , Processed in 0.087716 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表