unity tech.
이미지 로드해서 Image에 적용
zimamdero
2015. 9. 2. 16:16
로컬에 있는 이미지 WWW로 로드
public Texture2D LoadTextureByWWW(string path)
{
WWW www = new WWW("file://" + path);
return www.texture;
}
Sprite 만들기
public Sprite CreateSprite(string path)
{
Texture2D tex = LoadTextureByWWW(path);
return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
}
Image img;
img.overrideSprite = CreateSprite(imgPath);