- Home /
whitch images loaded from url
hi in a about to build photo album, in order to load an image ihave to use this method
// images are: "Lakshmi-Menon-Catalog-1.jpg" "Lakshmi-Menon-Catalog-2.jpg" "Lakshmi-Menon-Catalog-3.jpg"
public string url = "http://a7.idata.over-blog.com/500x348/3/27/08/34/jacqueline-
fernandez/Lakshmi-Menon-Catalog-1.jpg"; public int i;
IEnumerator Start() {
int x =0;
Debug.Log("strat called "+x++);
WWW www = new WWW(url);
yield return www;
renderer.material.mainTexture = www.texture;
}
so i tried to switch images using GUI
void OnGUI()
{
if(GUI.Button(new Rect(100,200,100,200),"next") && i <= 2 )
{
i++;
url = "http://a7.idata.over-blog.com/500x348/3/27/08/34/jacqueline-fernandez/Lakshmi-Menon-Catalog-"+i+".jpg";
// i have relalled strat method but the image didn't change
this.Start();
}
}
how can i switch between images using GUI ?
Answer by syclamoth · Oct 09, 2011 at 11:16 AM
You're trying to call start twice! That'll never work. You should put that functionality off into a separate method-
IEnumerator GetWWW() {
WWW www = new WWW(url);
yield return www;
renderer.material.mainTexture = www.texture;
}
And then use
StartCoroutine(GetWWW());
every time you wanted to change your image. Remember to give it a few seconds each time!
Answer by pegas7team · Oct 09, 2011 at 12:35 PM
thanks for help syclamoth it worked
Please, don't post that as an answer- just mark me as accepted! (also, upvotes are nice, but I really shouldn't ask for that)
Your answer
Follow this Question
Related Questions
Integrated VideoPlayer component but for images? 0 Answers
Application.OpenURL() Rapid Opening 1 Answer
Which "using directive" to use "Intent" for open url in android ? 1 Answer
Download Audioclip from youtube URL with WWW 2 Answers
url malformed cannot open file from streaming assets on windows 7 0 Answers