查看: 1000|回复: 0
打印 上一主题 下一主题

Unity3d 截图保存

[复制链接]

435

主题

2

听众

6371

积分

高级设计师

Rank: 6Rank: 6

纳金币
6372
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-8-28 17:37:41 |只看该作者 |倒序浏览
private var fileName : String = "screenShot";

function writeFile()

{

    var tex : Texture2D= new Texture2D(Screen.width,Screen.height,TextureFormat.RGB24, false);

    tex.ReadPixels(Rect(0,0,Screen.width,Screen.height),0,0);

    tex.Apply();

    var bytes : byte[]=tex.EncodeToPNG();

    Destroy(tex);

    var thisName : String = fileName+".png";

     var cachedAssetBundle =Application.dataPath+"/Resources/"+thisName;

    var cache = new System.IO.FileStream(cachedAssetBundle, System.IO.FileMode.Create);

    cache.Write(bytes,0,bytes.Length);

    cache.Close();

    Debug.Log("Cache saved: "+cachedAssetBundle);

   

}
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-5-21 23:44 , Processed in 0.078145 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部