반응형
Notice
Recent Posts
Recent Comments
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Archives
Today
Total
관리 메뉴

Do Something IT

[unity]Rendertexture screenshot to NGUI UITexture 본문

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;
 
    }
}
반응형

'Unity3D' 카테고리의 다른 글

문자 중 숫자만 남기고 모두 제거  (0) 2017.06.08
Vector3.Distance 와 sqrMagnitude 또는 magnitude 차이점  (0) 2017.05.22
Cant install visual studio community edition 2013  (0) 2016.07.28
라이브2D  (0) 2016.02.04
fps  (0) 2015.09.24
Comments