public static void SaveRTToFile()

{

RenderTexture rt = Selection.activeObject as RenderTexture;


RenderTexture.active = rt;

Texture2D tex = new Texture2D(rt.width, rt.height, TextureFormat.RGB24, false);

tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);

RenderTexture.active = null;


byte[] bytes;

bytes = tex.EncodeToPNG();


string path = AssetDatabase.GetAssetPath(rt) + ".png";

System.IO.File.WriteAllBytes(path, bytes);

AssetDatabase.ImportAsset(path);

Debug.Log("Saved to " + path);

}


์‰ฌ๋ฒŒ... Texture2D ๋ถ€๋ชจ ๊ฐ์ฒด ์ค‘์— RenderTexuter๋ผ๋„ ์žˆ์Œ???


์–ด๋–ป๊ฒŒ RenderTexture์— rt๋ฅผ ๋ถ™์˜€๋Š”๋ฐ ์ €๊ฑธ ์ฝ์–ด ๋“œ๋ฆฌ๋Š”๊ฒŒ ๋˜๋ƒ? - _ -


์‹ ๊ธฐํ•œ๊ฑฐ๋Š” ์ € ๋†ˆ๋“ค์€ ์ €๊ฒŒ ๋œ๋‹ค๋Š” ๊ฑธย ์–ด๋–ป๊ฒŒ ์•Œ์•„ ๋‚ธ๊ฑฐ์ง€?