Display downloaded image as new Sprite
So far I managed to download an Image and transform it into a Texture2D using this code:
public class ChangeTextureToImage : MonoBehaviour {
string url = "...";
Texture2D imgTexture;
public void getImageClick () {
StartCoroutine (LoadImg());
}
IEnumerator LoadImg(){
yield return 0;
WWW imgLink = new WWW (url);
yield return imgLink;
imgTexture = imgLink.texture;
}
Now I want to use this Texture to be displayed on a existing or new Sprite. I am familiar with this answer, but can't figure it out, how to use it on a material (don't understand this part:
public Material defaultMaterial; //prefab material set already
). How can I solve this? I tried and researched for the answer, but havent been able to solve it yet. Do you have an idea? Any help would be appreciated. Thanks
Comment