2월, 2018의 게시물 표시

유니티 텍스쳐 생성 (Unity Texture Create from bytes)

이미지
1. RenderTexture -> Texture2D -> bytes     private void GetRenderTextureBytes()     {         // 매프레임 new를 해줄경우 메모리 문제 발생 -> 멤버 변수로 변경         Texture2D txt = new Texture2D(texture.width, texture.height, TextureFormat.RGB24, false);         RenderTexture.active = texture;         txt.ReadPixels(new Rect(0, 0, texture.width, texture.height), 0, 0);         txt.Apply();         txtBytes = txt.EncodeToPNG();     } 2. bytes -> Texture2D     private Texture2D Base64ToTexture2D(byte[] imageData)     {               int width, height;         GetImageSize(imageData, out width, out height);         // 매프레임 new를 해줄경우 메모리 문제 발생 -> 멤버 변수로 변경         Texture2D texture = new Texture2D(width, height, Tex...