Created
February 7, 2017 12:03
-
-
Save RomainKurtz/dcf70dacf1a6c92bc63abef0105a4017 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void StartLoadingPhoto(){ | |
IEnumerator coroutine = LoadPhoto("http://website/photo.png"); | |
StartCoroutine(coroutine); | |
} | |
IEnumerator LoadPhoto(string url) | |
{ | |
string url = url; | |
Texture2D tex; | |
tex = new Texture2D(4, 4, TextureFormat.DXT1, false); | |
WWW www = new WWW(url); | |
yield return www; | |
www.LoadImageIntoTexture(tex); | |
Sprite sprite = Sprite.Create(tex, new Rect(0,0,300,300), new Vector2(0.5f, 0.5f), 100); | |
Photo.sprite = sprite; | |
//GetComponent<Renderer>().material.mainTexture = tex; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment