Unity 다운로드 이미지 표시방법
//예시
public Image raw;
private IEnumerator GetImageFiles(string fileName)
{
if(string.IsNullOrEmpty(fileName))
{
LogManager.ErrorLog("fileName is empty. Location : AIStudyExpansion->GetImageFiles");
yield break;
}
string url = string.Format("{0}{1}", Constant.AWS_ADDRESS, fileName);
var www = new WWW(url);
// wait until the download is done
yield return www;
// Create a texture in DXT1 format
Texture2D texture = new Texture2D(www.texture.width, www.texture.height, TextureFormat.DXT1, false);
// assign the downloaded image to sprite
www.LoadImageIntoTexture(texture);
Rect rec = new Rect(0, 0, texture.width, texture.height);
Sprite spriteToUse = Sprite.Create(texture, rec, new Vector2(0.5f, 0.5f), 100);
raw.sprite = spriteToUse;
www.Dispose();
www = null;
}