- Home /
Question by
Luca91 · Jun 15, 2013 at 01:13 AM ·
texturenetworkingwwwwww.texture
Problem while loading an image from url
Why this code works:
WWW www;
IEnumerator Start () {
www = new WWW( "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg" );
yield return www;
}
void OnGUI(){
GUI.DrawTexture(new Rect(0,0,100,100), www.texture, ScaleMode.StretchToFill);
}
And this doesn't work :
WWW www;
void Start () {
Loadfromweb();
}
IEnumerator Loadfromweb(){
www = new WWW( "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg" );
yield return www;
}
void OnGUI(){
GUI.DrawTexture(new Rect(0,0,100,100), www.texture, ScaleMode.StretchToFill);
}
Comment
Best Answer
Answer by clunk47 · Jun 15, 2013 at 02:11 AM
Because IEnumerator is a Coroutine. Saying LoadFromweb() would work ifyou had (void Loadfromweb). To access a coroutine / IEnumerator, us StartCoroutine like so:
StartCoroutine(Loadfromweb());
OR you can use a string.
StartCoroutine("Loadfromweb");
Hope this helps, friend :)
Your answer
Follow this Question
Related Questions
Host Image/Texture using Unity server, then request it using WWW on client 0 Answers
How to assign texture from url 1 Answer
Texture loading via www.texture not loading! 2 Answers
WebClient on Android 0 Answers
Image is not loading into Texture 0 Answers