I want to load a 20x11 .png image.
From this url - https://s19.postimg.org/izcdnvkoj/test_pixmap_kyubu.png
The location of the pixels are used to generate levels so I need to avoid resize.
I want to load a 20x11 .png image.
From this url - https://s19.postimg.org/izcdnvkoj/test_pixmap_kyubu.png
The location of the pixels are used to generate levels so I need to avoid resize.
private SpriteRenderer sprRend;
private void Awake()
{
this.sprRend = this.GetComponent<SpriteRenderer>();
this.StartCoroutine(this.LoadImage("https://s19.postimg.org/izcdnvkoj/test_pixmap_kyubu.png", 20, 11));
}
private IEnumerator LoadImage(string url, int width, int height)
{
WWW page = new WWW(url);
yield return page;
if (page.error != null)
{
Debug.LogWarning("Error: " + page.error);
}
else
{
Texture2D image = new Texture2D(width, height);
image.filterMode = FilterMode.Point;
if (image.LoadImage(page.bytes))
{
this.sprRend.sprite = Sprite.Create(image, new Rect(0, 0, image.width, image.height), Vector2.one * 0.5f);
}
else
{
Debug.LogWarning("Error: Could not load image");
}
}
}