- Home /
Streaming Tutorial anywhere?
Ok, struggling a bit here. Currently evaluating the Pro version and when it comes to streaming the information is somewhat scatter-shot. Is there a tutorial anywhere?
When I say 'streaming', I'm referring to the loading and unloading of assets within the same game level. For example: in a U shaped level, where items at one end of the U (area A) and items at the other end of the U (area B) are loaded in and out depending on the players proximity to area A and B.
- In area A the items of area B aren't visible or loaded
- At the mid point of the U, where although neither area is visible, both areas are loaded
- as the player goes around the last bit of corner, area B is now visible and area A is unloaded.
This is for a stand alone 3D PC game. Is this possible? I'm guessing it is.
The example project on the unity site has no documentation and Errors when it's loaded. Examples are good, but they explain nothing at all.
I'm still in the dark on Asset Bundles. Help!
Thanks for the link, but whilst working (yay), I'm still left completely in the dark as to the whole strea$$anonymous$$g/asset bundle aspect of Unity - CharacterCustomization contains no documentation.
I need salient info on how it works.
Answer by AliAzin · Mar 10, 2011 at 06:40 PM
Take a look at Character Customization example.
Thanks for the link, but whilst working (yay), I'm still left completely in the dark as to the whole strea$$anonymous$$g/asset bundle aspect of Unity - CharacterCustomization contains no documentation. I need salient info on how it works. $$anonymous$$artin 0 secs ago
note I've been digging around the web for a few hours now, I'm not doing the noob thing of just asking because I can't be bothered to hunt the info out. :)
Answer by Jaap Kreijkamp · Mar 10, 2011 at 10:34 PM
Wouldn't it in your case be much simpler to use Application.LoadLevelAdditiveAsync? Basically give every level segment it's own root gameobject and put it in its own scene, have a simple area manager that manages which segments needs to be loaded or unloaded, load with the LoadLevelAdditiveAsync and destroy gameobject root with all children when a segment has to be unloaded.
EDIT:
As apparently it isn't clear what I meant, I now linked back to the script reference so you can look it up. When playing with Unity, you must have walked into the concept of scenes. Basically it's all the game objects that are in Hierarchy viewer together and saved into a scene file.
With Application.LoadLevel
you can load different scenes, where every scene could for example represent a level in the game. When using Application.LoadLevel
you replace the scene, so all gameobjects that where in the scene before calling LoadLevel are deleted (except when marked as dontdestroybetweenscenes) and the new scene is loaded in. In your case you want to add things to your scene, not replace the scene.
Luckily there's an Application.LoadLevelAdditive
as well, that does load a new scene in, but leaves all game objects (the old scene) there. So, now you could put different segments of your level in different scene files and have these load in when getting close to them.
First, when going this route you'll notice some annoying game freeze when using Application.LoadLevelAdditive
, as the game is paused until the scene is loaded. That's why there's an LoadLevelAdditiveAsync
as well, this does the same, but in the background, so the scene won't be completely loaded directly after calling, but it will be loaded. The example in the script reference shows how you could use a Coroutine to be able to track when the loading is done, but you could go the simple way and just make sure the loading is triggered early enough so it's surely loaded before player is close enough to see it.
Now, how do you make the sections (scenes) load in on the fly? There you have to do some intelligent coding. The easiest way is put a block somewhere in the path the player can't get around with a trigger, and the trigger code calls the Application.LoadLevelAdditive
.
How to unload? The easiest way is by having a trigger object again that just calls Destroy on the objects that need to be removed. To make it easier it's smart to put everything of a sector under one root gameobject.
Just to be clear - assume I know nothing. mentioning 'application.LoadLevelAddiveAysnc' may as well read 'aerkabjlregiyuqbp5rigq'.
Now I understand that loading/unloading and visibility control is certainly not beginner stuff, but trying to find basic instructions on how Unity does this is like pulling teeth.
Thanks for the reply, and I'll add it to the quiver of knowledge that this topic is beco$$anonymous$$g in my head. Still seeking the ABC's of strea$$anonymous$$g though.
(Am I even using the term 'Strea$$anonymous$$g' right?)
If Application.LoadLevelAdditiveAsync is aerkabj.... to you, I'd say first get the hang of this kind of stuff before diving in something very advanced like level strea$$anonymous$$g, as strea$$anonymous$$g is quite advanced stuff and not that useful if you're playing directly from computer ins$$anonymous$$d of from a net player. I'll add some short explanation, but LoadLevelAdditiveAsync is really not that complicated and well explained in the scripting reference.