I am trying to get a web player to use LoadLevelAsync. Here are some of the problems.
What is the right way to use LoadLevelAsync?
Edited: Here's the code I am using. Maybe I am doing something wrong?
To invoke it
What happens is as follow:
1) On a streaming webplayer, I get the standard Unity3D blue screen (ie, when the scene is empty). The web player just loads the new level without loading any assets or creating objects for the new level.
2) On a non-streaming webplayer, all levels were already loaded, so it makes no difference.
You need to use Application.GetStreamProgressForLevel() to check if the level has already been downloaded. LoadLevelAsync will not download the level for you, it will just load the level objects while you are still playing, so you get rid of that short loading hickup.
If you need to download levels non-linearly, that is possible by using AssetBundles, but more complicated. Check out this example: http://unity3d.com/support/resources/example-projects/assetbundles
answered Jun 08 '10 at 03:57 PM
jonas echterhoff ♦♦
Have you read the doc? http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevelAsync.html
LoadLevelAsync allows you to load new levels while still playing the current one, show a progress bar or create a completely streaming world.
So if you have a menu level, you can load the level in the back while showing a loading bar and then switch to it, when it's ready :)
This is useful because when creating web players, you need to catch peoples attention fast. so a small starter level(plus dll's), play some music flashing color and so forth. then as soon as you'r in the menu, you start downloading lvl 1 so it's ready for the user.
In your scenario where the user can pick and choose, you really win download time for the menu level, but sadly you gotta download the level when the user pushes the button. Still useful because you can show a nice loading screen.
If you wanna read more about this kinda stuff, this is a okay read: http://unity3d.com/support/documentation/Manual/Web%20Player%20Streaming.html
Hope I helped :)
answered Jun 08 '10 at 12:41 PM
In addition to the above answers, be aware that the objects in your new level will have their Awake and Start functions called in the same thread as your loader level, so if all the work is happening in one of those functions, you're not going to see any incremental progress.
answered Jun 30 '11 at 01:24 AM