Search Unity

WWW is not ready downloading yet

Discussion in 'Scripting' started by herbie, Jan 23, 2014.

  1. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
    When my Android game is started, 3 images are loaded from the internet and are placed on planes like this:

    Code (csharp):
    1.  
    2. private var image1: WWW;
    3. private var image2: WWW;
    4. private var image3: WWW;
    5. public var Images: GameObject[]
    6.  
    7. function Start ()
    8. {
    9.     image1 = new WWW ("image1.png"); yield image1;
    10.     Images[0].renderer.material.mainTexture = image1.texture;
    11.     image2 = new WWW ("image2.png"); yield image2;
    12.     Images[1].renderer.material.mainTexture = image2.texture;
    13.     image3 = new WWW ("image3.png"); yield image3;
    14.     Images[2].renderer.material.mainTexture = image3.texture;
    15. }
    16.  
    This script is called loadingImages.js
    That's working fine.
    But if I call this function Start() from another script like this:
    Code (csharp):
    1. loadingImages.Start();
    I get the error WWW is not ready downloading yet.
    Why is yield image1 etc. only working when the game is started but not when the function Start() is called from another script?
     
  2. AngryGenius

    AngryGenius

    Joined:
    Jan 21, 2014
    Posts:
    14
    Start is called as a coroutine at the beginning of the game, so use StartCoroutine() to start it from other scripts. :)
     
  3. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
    Thanks!

    How exactly do I use StartCoroutine() ?

    otherscript.StartCoroutine() is not working.
     
  4. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
    I did it like this:
    otherscript.StartCoroutine("Start");
    But it still says that WWW is not ready downloading yet.

    When I use application.loadlevel it's working fine but I don't want to start the whole game.
     
  5. AngryGenius

    AngryGenius

    Joined:
    Jan 21, 2014
    Posts:
    14
    Hiya again! I haven't done much UnityScript, but calling Start like
    Code (csharp):
    1. StartCoroutine(otherscript.Start());
    Should help! :)
     
  6. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
    It is still not working.
    It still says that WWW is not ready downloading yet.
    Maybe that it has something to do with Android.

    Why is "yield image1" not working?
    "isDone" is also not working.

    Pfff, I have a hard time.