Unity3D
[unity]Rendertexture screenshot to NGUI UITexture
아낙시만더
2017. 1. 2. 15:39
반응형
출처 : 바로가기
using UnityEngine; using System.Collections; public class TakeScreenShot : MonoBehaviour { public Camera RenderCam; public UITexture tex; private Texture2D image; private int width = 863, height = 402; public void CaptureImage() { RenderTexture rt = new RenderTexture(width, height, 24); image = new Texture2D(width, height, TextureFormat.ARGB32, false); //Camera settings RenderCam.aspect = 1.0f; RenderCam.targetTexture = rt; RenderCam.Render(); RenderTexture.active = rt; image.ReadPixels(new Rect(0.0f, 0.0f, width, height), 0, 0); image.Apply(); tex.mainTexture = image; RenderTexture.active = null; RenderCam.targetTexture = null; } }
반응형