Unity使用RenderTexture进行截屏
2015-10-29 16:54
579 查看
private IEnumerator cutScreen() { RenderTexture rt = new RenderTexture(Screen.width, Screen.height, 24); m_mainCam.targetTexture = rt; m_mainCam.Render(); m_auxCam.targetTexture = rt; m_auxCam.Render(); m_nguiCam.targetTexture = rt; m_nguiCam.Render(); RenderTexture.active = rt; Texture2D tex = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); tex.ReadPixels(new Rect(0,0,Screen.width,Screen.height),0,0); tex.Apply(); RenderTexture.active = null; m_mainCam.targetTexture = null; m_auxCam.targetTexture = null; m_nguiCam.targetTexture = null; Destroy(rt); GameObject photo = new GameObject("photo"); UITexture uiTex = photo.AddComponent<UITexture>(); uiTex .mainTexture = tex; photo.transform.parent = m_gamePanel.transform; photo.transform.localPosition = new Vector3(); photo.transform.localScale = Vector3.one; uiTex.width = 611; uiTex.height = 344; yield return null; }
相关文章推荐
- Unity3D——android device 真机发布调试
- Unity在场景切换之间清理下内存
- UNITY 5.2 PlayerPrefs类
- Unity3D研究院之DontDestroyOnLoad的坑
- Unity 客户端知识体系
- unity中对于scrollview下拉加载的方法
- Unity中单例模式的使用
- Unity3D之AssetBundle资源加载封装
- 新手引导
- Unity3DAssetBundle的坑
- 增强现实(AR)笔记:Vuforia及Unity3D
- unity抛物线,平均速度下的运动轨迹
- Unity如何将包缩小到极致
- 自学Unity之做一个MOBA游戏4——小兵
- unity之RotateAround 一个物体围绕另外一个物体旋转
- OccTransVF
- XRay7
- UNITY 5.2 Application类
- Xray6
- Unity Shader入门