One webplayer loader, many possible streamed games

Alright, so here is my situation. I am building multiple multiplayer webplayer games, which are meant to be played in a specific website. These webplayer games all share a common, small first scene that handles website chat, my custom login scripts, and networking in general.

Here’s what I’d like to happen. The initial small scene is loaded as soon as a user opens the webpage, and logs in to our custom server and does various network things. Then, the user selects a game to play, and the initial scene streams in the selected game, and then the user can play it. The initial scene stays connected during all of this.

How can I make this happen with Unity? Here are the options I’ve thought about:

  • AssetBundles. These sounded ideal at first, as a way to package the whole game as a bundle that I could stream in, then play right there. Unfortunately, AssetBundles seem to have severe limitations on what you can actually put in them, for instance scenes or scripts seem prohibited in AssetBundles, so this doesn’t seem to work to bundle a game.

  • WWW.LoadUnityWeb(). This sounded pretty good until I read the following from the documentation: “All objects, scripts and static variables from the previous .unity3d file will be unloaded.” I want my initial loader scene to remain loaded at all times, so this doesn’t seem right for me.

  • Level streaming. With the built-in level streaming feature, I could make each game as a separate level of one mega-project, then stream in the selected game at will. This actually sounds like it could work well, but it seems very unwieldy to mash-up all my games in one giant Unity project.

So far it sounds like level streaming is my only option, but I’d love to be proven wrong. Is there an option I’ve overlooked?

level streaming through asset bundle isn’t all that bad actually :slight_smile:
But yes technically its your only option, as asset bundles don’t transport scripts and you don’t want the initial scene to be wiped out (the webplayer is basically replaced)

Thanks for the reply, I guess I’ll have to bite the bullet and merge everything. If I could request a feature, I’d request something to stream whole games in, as this will make maintenance a pain in the rear.

Hmm, actually, even level streaming doesn’t seem to quite fit the bill. If I understand correctly, Unity will stream in Level 1, then Level 2, then Level 3, and so on without any work on my part. But in my case, maybe I want to stream in Level 1 (initial scene), then Level 3 (Game #2), without even loading Level 2 (Game #1) at all.

If the user wants to play Game #4, I don’t want him to have to wait for games #1 through #3 to get streamed in first! What can I do?

After thinking about it a bit, I decided to drop the approach of keeping an initial scene loaded at all times, since that apparently doesn’t work too well with Unity, and just give the illusion of a continuous connection when switching games by storing some session info in javascript on the browser side, and having the common initial scene on all games be very small and load up first. Then, I just fully unload the old game, and fully load up the new one every time.

The small connection downtime every time I switch games is unfortunate, but we can deal with it. Too bad Unity did not support what I wanted to do, oh well.