Search Unity

Strange behaviour on LoadUnityWeb( )

Discussion in 'Editor & General Support' started by hgbimonti, Jun 20, 2009.

  1. hgbimonti

    hgbimonti

    Joined:
    Dec 31, 2008
    Posts:
    19
    Hello!

    I'm working on a race game that will be played online, with various cars and tracks.

    The game has more than 6 tracks, each one has a lot of assets and, of course, it gets heavy for download everything every time you play. It would be interesting that if you are playing the first track, there is no need to get the other five.

    So, I decided to use the LoadUnityWeb function, that I already used in other project that worked nice.

    This project has various scenes because, besides the tracks, we have many menus and options scenes, like quick race, time trial, car selection, etc.

    There we go:

    I splited some scenes in some .unity3d files. For example: LanguageSelection, SplashScreen and Loading scenes are in the Start.unity3d file. Menu, QuickRace, TimeTrial and LoadTrack scenes are in the Menu.unity3d. Then we have Track1 and LoadNextTrack scenes are inside the Track1.unity3d file that is in the /tracks/ folder.

    It's working ok when loading them sequentialy. The strange problem is happening when I am in the Track1 scene, that is inside the Track1.unity3d file, and click on the option "Main Menu" that is on the GUI of the track. When I select this option I just start downloading the file Menu.unity3d. When it's done I call the LoadUnityWeb() and it loads the MainMenu scene on screen. BUT, when I advance to the next scene (QuickRace scene), that is in this same unity3d file that just loaded and showed the first MainMenu scene, the QuickRace scene does not load at all!!! See that it's the same file that worked ok when loaded the first time sequentially! I'm really not getting it.

    All this when using Firefox. The weirdest is when I try this on Safari. It loads the MainMenu scene, the next one that is the QickRace AND finally crashes when I advance to the next SelectCar scene.

    Two browsers and two different behaviours: Firefox load only the MainMenu scene. Safari load MainMenu, QuaickRace but crashes on loading the next.

    Does anybody has any idea of what is going on? And how can I get this to work using the LoadUnityWeb()?

    I don't know if there is some specification or limitation of the LoadUnityWeb function. I took a look at the documentation but didn't find anything.

    The Unity support guys, any help would be nice!

    Sorry on the long thread and my not so good English.

    Thank you!

    Rock On,

    Higor
     
  2. Lucas Meijer_old

    Lucas Meijer_old

    Joined:
    Apr 5, 2008
    Posts:
    436
    I would recommend using BuildPipeline.BuildPlayer() to create assetbundles that contain self contained scenes, and then using the WWW class to download them.

    use BuildOption.BuildAdditionalStreamedScenes (give or take a typo) when creating the additional files. You still need to keep those scenes in your build settings, but they can be check off. so they don't get included in your main game file.

    then from your main gamefile, just WWW load all the levels in. They become available for regular Application.LoadLevel() usage once you have done:

    AssetBundle dummy = mywww.assetBundle;

    (or something similar in javascript). basically you need to refer to the .assetBundle property, and from that point on you can safely Load the level. (works with additive loading too).

    Good luck, Lucas
     
  3. hgbimonti

    hgbimonti

    Joined:
    Dec 31, 2008
    Posts:
    19
    Thank you, Lucas. That just worked really nice!

    :D