
[Unity]摄像机动态人物头像&截图&TargetTexture问题
发布日期:2021-05-09 11:54:54
浏览次数:2
分类:技术文章
本文共 1235 字,大约阅读时间需要 4 分钟。
在实现动态人物头像 的时候(相关文章1),同时 实现 截屏 功能,会出现
实现截屏的功能,主要是 相关文章2 的内容
private Texture2D CaptureScreen(Camera came, Rect r) { string screenShot_ = GameSetting.instance.screenShotPath;//使用一个 脚本 专门储存 固定的内容,便于调用 RenderTexture rt = new RenderTexture((int)r.width, (int)r.height, 0); came.targetTexture = rt; came.Render(); RenderTexture.active = rt; Texture2D screenShot = new Texture2D((int)r.width, (int)r.height, TextureFormat.RGB24, false); screenShot.ReadPixels(r, 0, 0); screenShot.Apply(); came.targetTexture = null; RenderTexture.active = null; GameObject.Destroy(rt); came.GetComponent().targetTexture = renderer_tex;// byte[] bytes = screenShot.EncodeToPNG(); string filename = screenShot_ + "/ScreenShot.png"; System.IO.File.WriteAllBytes(filename, bytes); return screenShot; }
调用截屏 函数
Rect r = new Rect(new Vector2(0,0), new Vector2(250, 250)); CaptureScreen(camera, r);
------------------------截屏后,会出现
声明 变量
public RenderTexture renderer_tex;//显示动态 人物头像的 renderer
并在 上面的 截屏函数中 如果没有旧 添加 一句 代码
came.GetComponent().targetTexture = renderer_tex;//
相关文章:
1.
2.
3.
4.
[Unity]动态人物头像
转载地址:https://blog.csdn.net/BuladeMian/article/details/79342583 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
表示我来过!
[***.240.166.169]2023年09月12日 18时49分25秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
库函数之malloc与calloc
2019-03-07
库函数之malloc与new
2019-03-07
库函数之sprintf与snprintf
2019-03-07
库函数之scanf与sscanf
2019-03-07
Linux命令之lsusb
2019-03-07
嵌入式Linux开发,去掉内核kernel开机画面logo屏幕上的光标
2019-03-07
Linux,curl工具,测试web,数据流直接打印到控制平台
2019-03-07
Element-UI安装使用教程(一)
2019-03-07
Vue开发入门(一) | vue基础指令 &案例
2019-03-07
PHP开发入门(一) | php基础语法知识
2019-03-07
WebStorm 中安装并使用Element-UI(入门)
2019-03-07
Element-UI开发指南--动画和组件基础(二)
2019-03-07
Vue+Bootstrap实现商品的增删计算案例
2019-03-07
设计素材网址集合(比较全)
2019-03-07
Liunx配置DNS服务器
2019-03-07
Liunx配置主DNS服务操作案例
2019-03-07
css+html鼠标划入hover效果(一)
2019-03-07
常用正则表达式(重要)
2019-03-07
Python3进阶(二) | 正则表达式
2019-03-07
Python绘图 | 初识Turtle绘图~
2019-03-07