Search Unity

[url]www.LoadImageIntoTexture[/url]

Discussion in 'Editor & General Support' started by seon, Jun 23, 2007.

  1. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    Why is this in a while loop in all examples in the docs?

    Code (csharp):
    1. function Start () {
    2.     renderer.material.mainTexture = new Texture2D(512, 512);
    3.     while(true) {
    4.         var www = new WWW(url);
    5.        
    6.         yield www;
    7.        
    8.         www.LoadImageIntoTexture(renderer.material.mainTexture);
    9.     }
    10. }
    If the code waits for the yield.. what's the while loop for? and how is it passed a false to break the endless loop?
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    The idea is that the texture is coming from a web cam that keeps on changing.
    So you basically get an animated view of the web cam in 3D. Thats what the while loop is for. If you only want to download the image, just remove the while loop.
     
  3. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    Ok, that not only makes sense.. but is cool !
    Thanks Joachim :)