04b0d121e0e13db27ab6d8b258c12a3ae0443002773819ffe03613

1. ์Šคํ”„๋ผ์ดํŠธ๋ฅผย ๋ฉ€ํ‹ฐํ”Œ๋กœ ํ•˜๊ณ  ์—๋””ํ„ฐ์—์„œ ์›ํ•˜๋Š”๋Œ€๋กœ ์Šฌ๋ผ์ด์Šค ํ•œ๋‹ค

2. Read/Write Enabled ์ฒดํฌ

3. ํฌ๋งท ๋ฐฉ๋ฒ•์„ ํŒŒ์ผํ™”์— ํ˜ธํ™˜๋˜๋Š” ๊ฑธ๋กœย ์„ค์ •ํ•œ๋‹ค. (RGBA 32bit ์ถ”์ฒœ)

4. Apply๋ฅผ ๋ˆ„๋ฅธ๋‹ค.


using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; public class TextureToImage : MonoBehaviour { public Sprite[] sprites; // Start is called before the first frame update void Start() { foreach (var sp in sprites) { int x = Mathf.FloorToInt(sp.textureRect.x); int y = Mathf.FloorToInt(sp.textureRect.y); int width = Mathf.FloorToInt(sp.textureRect.width); int height = Mathf.FloorToInt(sp.textureRect.height); Texture2D t2d = new Texture2D(width, height); Color[] c = sp.texture.GetPixels(x, y, width, height); t2d.SetPixels(c); t2d.Apply(); File.WriteAllBytes(Application.dataPath + "/../" + sp.name + ".png", t2d.EncodeToPNG()); } } }


5. ์Šคํฌ๋ฆฝํŠธ ์ž‘์„ฑ

6. ์˜ค๋ธŒ์ ํŠธ ํ•˜๋‚˜ ๋งŒ๋“ค๊ณ  ์Šคํฌ๋ฆฝํŠธ ์ง‘์–ด๋„ฃ๊ณ  sprites์—๋„ ์Šคํ”„๋ผ์ดํŠธ๋“ค๋„ ์ง‘์–ด ๋„ฃ๋Š”๋‹ค.

7. ์‹คํ–‰


3dafdf20ecc676b660b8f68b12d21a1d4d8cd6efc7


8. Profit!


๋ฐ‘์— ์งˆ๋ฌธ ์žˆ๊ธธ๋ž˜ ์•Œ์•„๋ด„