x


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 ?

more ▼

asked Oct 09 '11 at 11:05 AM

pegas7team gravatar image

pegas7team
1 1 1 2

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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!

more ▼

answered Oct 09 '11 at 11:16 AM

syclamoth gravatar image

syclamoth
14.8k 7 15 80

(comments are locked)
10|3000 characters needed characters left

thanks for help syclamoth it worked

more ▼

answered Oct 09 '11 at 12:35 PM

pegas7team gravatar image

pegas7team
1 1 1 2

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)

Oct 09 '11 at 12:36 PM syclamoth
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x54
x53
x3

asked: Oct 09 '11 at 11:05 AM

Seen: 633 times

Last Updated: Oct 09 '11 at 12:36 PM